Search code examples
javascriptsmartclient

How to make selection on drop down list (DynamicForm) using JavaScript in SmartClient?


Here is a drop down list in SmartClient: http://www.smartclient.com/#dropdownGrid.

I want to make a selection using JavaScript. Like, I run some JavaScript in console, and the drop list will select a specific item.

I did some research, found a code snap to do this (the code is in Java, but I think there should be similar functions in JavaScript):

Record rec = perdomainGrid.getRecordList().find("domaine_id", domaine_id);
perdomainGrid.selectSingleRecord(rec); 

If I want to make selection, first I need to obtain perdomainGrid object. In my above giving link, the drop down list id in GWT is exampleForm (can be seen in dropDownGrid.js tab). I try to get the object by:

var form = isc.DynamicForm.getById("exampleForm");

form does exist, but there is no getRecordList() function on it, there is selectSingleRecord() function on it though.

I try to check form's class by form.className, its value is normal. I don't know what does that mean.

I'm kind of confused now. Could somebody help me on this?


Solution

  • isc_SelectItem_5 has a function called pickValue(), it takes one parameter SKU. This function can be used to select item.

    var itemName = "Letter Tray Front Load Tenex 200 Class Blk #23001";
    var data = isc_SelectItem_5.optionDataSource.cacheData;
    var targetSKU = data.find(function(e) {
        if (e.itemName == itemName) {
            return e;
        }
    }).SKU;
    isc_SelectItem_5.pickValue(targetSKU);