Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Select And Picklist

    Hello, I am trying to setContents an text object inside in DynamicForm.
    The value to set, into of text control, it comes from an pickList,
    but I cannot do it.

    There are examples that show something like that, if it is possible to do it, of course.

    I attached brief source code in code.js. Take in concern, this code is a shortly version.

    Arms.

    #2
    Missing attachment, but probably best if you make another attempt to explain exactly what you want, we weren't able to understand.

    Comment


      #3
      Ok, here you can see the brief code.

      Code:
       
      ,
              {
                  textAlign:"right",
                  name:"ORDERPARAMETER",
      	 autoFetchData:false,
                  valueField:"ORDER",
                  optionDataSource:"parameters",
                  title:"Id parameter",
                  colSpan:4,
                  type:"select",
                  _constructor:"FormItem",
                  pickListProperties:{
                      sortFieldNum:0,
                      _constructor:"ListGrid"
                  },
                  pickListWidth:"450",
                  pickListFields:[
                      {
                          name:"ORDER",
                          align:"right",
                          masterIndex:"0",
                          title:"Order",
                          primaryKey:"true",
                          required:"true",
                          type:"integer",
                          validators:{
                              elem:{type:"isInteger", typeCastValidator:"true", _generated:"true", 
                               stopIfFalse:"true",defaultErrorMessage:"Must be a whole number.", 
                               resultingValue:"1"}
                          },
                          width:null,
                          height:null,
                          canDrag:"false",
                          canDragResize:"false",
                          canDrop:"false"
                      },
                      {
                          name:"DESCRIPTION",
                          align:"left",
                          masterIndex:"1",
                          title:"Description",
                          type:"text",
                          length:"50",
                          validators:{
                              elem:{type:"isString", typeCastValidator:"true", _generated:"true", 
                               stopIfFalse:"true"}
                          },
                          width:null,
                          height:null,
                          canDrag:"false",
                          canDragResize:"false",
                          canDrop:"false"
                      }
                  ],
      	 getPickListFilterCriteria: function() {
      		var fndParameter = grdTemplates.getSelectedRecord().ORDER;
      		var rtnCriteria;
      		// if (fndParameter != null) {
      			rtnCriteria = {ORDERTEMPLATE:fndParameter};
      			return rtnCriteria;
      		// }
      		}
              },
              {
                  textAlign:"left",
                  name:"DESCRIPTION",
                  disable:true,
                  width:500,
                  ID:"txtDescValue2",
                  title:"Description",
                  _constructor:"TextItem"
              },
      I am trying to complete a text object inside of DynamicForm. This form is bound to one datasource. I defined each objects and its type, explicitly, inside the dynamic form, to hold by those objects, the values from the selected record.

      One of these texts objects, defined in the dynamic form, is "Select" type. It include a picklist with an optional datasource.

      The picklist has more than one column. I want, when I do click over one record on the picklist, is to catch a value from an specific column and put it on other text object that reside inside of the same dynamic form, you might see it with name "txtDescValue2" and disable:true, to show description of the selected value on the "Select" object.

      Is it possible to do it?.

      If you need to view the code, tell me.

      Thank,
      Carlos.

      Comment


        #4
        Use the changed() event, call getSelectedRecord() and call setValue().

        Comment


          #5
          Sorry, but didn't work it.
          Here my code

          Code:
          isc.Page.setAppImgDir("/tools/visualBuilder/graphics/");
          
          isc.DataSource.create({
              dataFormat:"iscServer",
              fields:{
                  ORDER:{title:"Id Order", required:true, type:"int", name:"ORDER"},
                  ORDERPARAMETER:{title:"Id Parameter", primaryKey:true, required:true, type:"int", name:"ORDERPARAMETER"},
                  ORDERITEM:{title:"Id Item", primaryKey:true, required:true, type:"int", name:"ORDERITEM"},
                  DESCRIPTION:{
                      title:"Description",
                      primaryKey:true,
                      type:"text",
                      length:70,
                      name:"DESCRIPTION"
                  }
              },
              dbName:"Oracle",
              ID:"values",
              serverType:"sql",
              tableName:"VALUES"
          });
          
          
          isc.DataSource.create({
              dataFormat:"iscServer",
              fields:{
                  ORDER:{title:"Order", primaryKey:true, hidden:true, type:"integer", name:"ORDER"},
                  ORDERTEMPLATE:{title:"Template", hidden:true, type:"integer", foreignKey:"templates.ORDER", 
                   name:"ORDERTEMPLATE"},
                  DESCRIPTION:{
                      title:"Description",
                      type:"text",
                      length:30,
                      name:"DESCRIPTION"
                  }
              },
              dbName:"Oracle",
              ID:"parameters",
              serverType:"sql",
              tableName:"PARAMETERS"
          });
          
          
          isc.DynamicForm.create({
              dataSource:parameters,
              ID:"DynamicForm1",
              autoDraw:false,
              fields:[
                  {change:"var getDesc = this.getSelectedRecord().DESCRIPTION;\nif (getDesc != null) {\n      DynamicForm1.setValue(txtDesc, getDesc);\n}\n", 
                   name:"txtOrder",valueField:"ORDER", type:"select", optionDataSource:"values", _constructor:"FormItem"},
                  {name:"txtDesc", _constructor:"FormItem"}
              ]
          })
          
          
          isc.VLayout.create({
              members:[
                  DynamicForm1
              ],
              autoDraw:true,
              overflow:"hidden",
              width:"100%",
              ID:"VLayout1",
              height:"100%"
          })
          I am trying to do it on the event change, but I couldn't.

          When I change the value, the error message referencing to 'this' object, is null or not an object.

          I am using 'this' because the 'select' object has optional datasource, to use getSelectedRecord() and to get description value.

          Any suggestions?.

          Comment


            #6
            changed with a "d", not change.

            No need to use "this", use "item", which refers to the current item. You also have "form" available to refer to the current form. Search the docs for "StringMethod" to understand how this works.

            Comment


              #7
              I did these changes and worked fine.

              But in my project it didn't work.

              Code:
                          changed: function () {
              		var getDescription = pickListItem.getSelectedRecord().DESCRIPTION;
              		if (getDescription  != null) {
              			alert('HERE YOU UP');
              			// addValues.setValue('txtDescValue2', getDescription);
              		}
              		else {
              			alert('NOTHING');
              			// addValues.setValue('txtDescValue2', 'NOTHING');
              		}
                          },
              Is it correct to use pickListItem.getSelectedRecord().DESCRIPTION, to get the description?.

              The object definition is:

              Code:
                          ...,
                          optionDataSource:"parameters",
                          title:"Id Parameter",
                          colSpan:4,
                          type:"select",
                          _constructor:"FormItem",
                          pickListProperties:{
                              sortFieldNum:0,
                              _constructor:"ListGrid"
                          },
                          ...,
              Thanks.

              Comment


                #8
                Yes, that's correct. Try binding a ListGrid to your "parameters" DataSource, perhaps DESCRIPTION really is null in the database.

                Comment


                  #9
                  Why do you suggest me that bind the datasource parameters to a ListGrid?. Don't forget that everything are in a dynamic form.

                  There is a combox (pickList) with more than one column.

                  Or

                  Are you suggest me replace the pickList object with a ListGrid inside of dynamic form?

                  Thanks.

                  Comment


                    #10
                    The purpose of binding to a ListGrid is to quickly see if valid data for the DESCRIPTION field is being returned to SmartClient through the "parameters" DataSource. In other words, it's a means of debugging the problem.

                    Comment


                      #11
                      Is this what you indicate me?. Because it work fine.

                      Code:
                      isc.Label.create({
                          title:"Label0",
                          autoDraw:false,
                          contents:"Label",
                          styleName:"textItem",
                          ID:"Label0",
                          height:20
                      })
                      
                      
                      
                      isc.DataSource.create({
                          dataFormat:"iscServer",
                          fields:{
                              ORDER:{title:"Order", primaryKey:true, hidden:true, type:"integer", name:"ORDER"},
                              ORDERTEMPLATE:{title:"Template", hidden:true, type:"integer", foreignKey:"template.ORDER", 
                               name:"ORDERTEMPLATE"},
                              DESCRIPTION:{
                                  title:"Description",
                                  type:"text",
                                  length:30,
                                  name:"DESCRIPTION"
                              }
                          },
                          dbName:"Oracle",
                          ID:"parameters",
                          serverType:"sql",
                          tableName:"PARAMETERS"
                      })
                      
                      
                      
                      isc.ListGrid.create({
                          dataSource:parameters,
                          ID:"ListGrid0",
                          autoFetchData:true,
                          autoDraw:false,
                          recordClick:"var getDesc = ListGrid0.getSelectedRecord().DESCRIPTION;\nif (getDesc != null) {\nLabel0.setContents(getDesc);\n}\nelse { Label0.setContents('NOTHING');}",
                          cellHoverHTML:null
                      })
                      
                      
                      
                      isc.VLayout.create({
                          members:[
                              Label0,
                              ListGrid0
                          ],
                          autoDraw:true,
                          overflow:"hidden",
                          width:"100%",
                          ID:"VLayout2",
                          height:"100%"
                      })

                      Comment


                        #12
                        Hi Cavo,

                        If you are definitely seeing that the DESCRIPTION field is being returned to SmartClient (another place to look is the RPC tab in the Developer Console), then we'll probably need to show complete code for this interaction. Our consulting team uses this feature (getSelectedRecord().someFieldName) on a constant basis and it's definitely a working technique.

                        Comment

                        Working...
                        X