Ok - I think this will do what you want:
Continue to use getPickListFilterCriteria() to control what options show up in the second select item.
Have a “changed” handler on the first select item that clears out the value of the second select item. This solves the problem of the value of the second item being out of date.
Have a changed handler on both the second and third items that calls ‘filter()’ on your ListGrid, passing in the current values from the form.
Note: using ‘changed’ rather than ‘change’ gives you the advantage that the newly entered value has been saved and is availble as this.getValue() / form.getValue(‘fieldName’)).
Code to demonstrate this (using the “supplyCategory” / “supplyItem” dataSources, since they’re available in the SDK)
// Assume your list grid is called "itemList"
isc.SearchForm.create({
ID:"findForm",
fields:[
{name:"category", editorType:"select",
optionDataSource:"supplyCategory",
// get rid of out of date values in the second select when this
// value changes
changed:"form.getItem('itemName').setValue(null);"
},
{name:"itemName", editorType:"select",
optionDataSource:"supplyItem",
// filter set of options based on value of first field
getPickListFilterCriteria:function () {
return {category:findForm.getValue("category")};
},
// filter data on the listGrid on change
changed:"itemList.filterData(form.getValues());"
},
{name:"type", editorType:"select",
valueMap:["ea", "roll", "pkt"],
// filter listGrid on change
changed:"itemList.filterData(form.getValues());"}
]
});
You should find with this code:
- when you click on the first select item, it shows all the options from the supplyCategory dataSource.
- when you click on the second select item, it shows only the values from the supplyItem dataSource that match the value of the first
- when you select a value from the first select item it clears out the current value of the second select (and changes the filter criteria so next time the second select is clicked the set of possible options will be different).
- when you select a value from either the second or third item, the ListGrid data is updated based on the filter criteria.
I think this covers all your requirements - let us know if we’ve missed something. There are other approaches, but this is probably the easiest, if we understand your problem correctly.
Thanks