Announcement

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

    Picklist does not return the selected record when the value is set programmatically

    I can create a picklist, multi-column combobox, and set the value programmatically. The function getValue() returns the correct value. The function getSelectedRecord() returns 'undefined'.
    Is setting the value suppose to select the record with the corresponding value?

    Code:
    <!DOCTYPE html>
    <html>
    <head>
      <title></title>
      <meta charset="utf-8" />
    </head>
    
    <body>
    
    <script type="text/javascript"> var isomorphicDir = "/isomorphic/";</script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_Core.js"></script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_Foundation.js"></script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_Containers.js"></script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_Grids.js"></script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_Forms.js"></script>
    <script type="text/javascript" src="/isomorphic/system/modules/ISC_DataBinding.js"></script>
    @
    <script type="text/javascript">
    
    var _cboDsConfig = [];
    
    isc.DataSource.create({
      ID: "_dsConfigSchema",
      fields: [
        { name: "DisplayID" , title: "Config ID" , type: "text", length: 40 },
        { name: "Title" , title: "Title" , type: "text", length: 40 },
        { name: "Description", title: "Description", type: "text", length: 255 },
        { name: "Datime" , title: "Date" , type: "text", length: 40 },
        { name: "ID" , title: "ID" , type: "text", length: 40 }
      ],
    
    clientOnly: true
    });
    
    
    isc.DynamicForm.create({
      ID: "_cboConfigDdl",
      left: 0,
      titleSuffix: "",
      zIndex: 100,
      width: 715,
      height: 20,
      fields: [
        {
          ID: "_cboConfigFields",
          type: "select",
          width: 715,
          clientOnly: true,
          optionDataSource: _dsConfigSchema,
          autoFetchData: false,
          canEdit: false,
          valueField: "ID",
          displayField: "DisplayID",
          pickListWidth: 715,
          pickListFields: [
            { name: "DisplayID" , width: 70 },
            { name: "Title" , width: 250 },
            { name: "Description", width: 300 },
            { name: "Datime" , width: 70 },
            { name: "ID" , width: 1, type: "hidden" }
          ]
        }
      ] // fields
    
    }) // DynamicForm
    
    
    // Return object to be appended to data source
    function AddConfig(displayID, title, description, datime, id) {
      var obj = new Object();
      obj.DisplayID = displayID;
      obj.Title = title;
      obj.Description = description;
      if (arguments.length > 3) {
        obj.Datime = datime;
        if (arguments.length > 4)
          obj.ID = id;
      }
      return obj;
    }
    
    _cboDsConfig.push(AddConfig('1st - Display', '1st - Title', '1st - Description', '1st - Date', '1st - ID'));
    _cboDsConfig.push(AddConfig('2nd - Display', '2nd - Title', '2nd - Description', '2nd - Date', '2nd - ID'));
    _cboDsConfig.push(AddConfig('3rd - Display', '3rd - Title', '3rd - Description', '3rd - Date', '3rd - ID'));
    _cboDsConfig.push(AddConfig('4th - Display', '4th - Title', '4th - Description', '4th - Date', '4th - ID'));
    
    _cboConfigFields.optionDataSource.testData = _cboDsConfig;
    _cboConfigFields.fetchData();
    _cboConfigFields.enable();
    _cboConfigFields.canEdit = true;
    
    _cboConfigFields.setValue('3rd - ID');
    var v = _cboConfigFields.getValue();
    var r = _cboConfigFields.getSelectedRecord();
    alert('getValue: ' + v);
    alert('getSelectedRecord: ' + r);
    
    </script>
    
    </body>
    
    </html>

    #2
    I forgot the basics. I am using SmartClient_v111p_2017-09-14_LGPL in IE 11.

    Comment


      #3
      You will find that getSelectedRecord() will return the record as expected, if you actually wait for the data to come back from the server. In your test code you are not waiting.

      Comment


        #4
        I am using the LGPL version and I am not waiting because the data source is clientOnly: true. No server is involved for data.

        Comment


          #5
          clientOnly DataSources fully simulate a remote DataSource, hence are asynchronous.

          Comment

          Working...
          X