Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
985
igCombo - How to find Json Data object from selected combo value
posted

I would like to find other data values of json object  passed as datasource to igCombo, How can I do that in  selectionChanged method?

$(this).igCombo({

dataSource: jsonColumnSchema.Visible,

textKey:  "headerText",

valueKey:  "key",

autoComplete: true,

selectedItems : [{index: 0}],

enableClearButton : false,

width: "200px",

height:"25px",

selectionChanged: function (evt, ui) { var fieldName = ui.items[0].value;}

});

Parents
  • 24497
    Verified Answer
    posted

    Hi Annasaheb,

    To get reference to original dataSource, application may use options.dataSource member, which is set on initialization of igCombo. If dataSource is string (like netflex oData), or if application uses dataSourceUrl, then the best I can suggest, is to use internal member variable _dataSource. That member contains reference to instance of internal $.ig.DataSource object.

    Below is example:

      $("#combo1").igCombo({
       textKey: 'a',
       valueKey: 'id',
       selectedItems: [{index: 0}],
       dataSource: [ {a: 'one', id: 1, val: 123 }, {a: 'two', id: 3, val: 345 }, {a: 'three', id: 3, val: 678 }],
       selectionChanged: function (evt, ui) {
        var item, index, str = 'no selection',
         ds = ui.owner.options.dataSource,
         _ds = ui.owner._dataSource,
         selItems = ui.items,
         selItem = selItems ? selItems[0] : null,
         index = selItem ? selItem.index : -1;
        if (index >= 0) {
         item = ds ? ds[index] : null;
         if (!item) {
          item = _ds.dataView()[index];
         }
         str = 'index: ' + index + ', a: ' + item.a + ', val: ' + item.val;
        }
        alert(str);
       }
      });

Reply Children
No Data