[dojo] Related Selection
In many cases we need to change ComboBox/FilteringSelect options based on selection in another ComboBox. In dojo, I haven’t found a way to programmatically update the items in the Combobox/FilteringSelect widget, if they are connected to a datastore.
Now, my idea is as follows:
1. fetch a subset of datastore using query.
2. use an empty ItemFileWriteStore to save the result of the query.
3. assign the writestore to the ComboBox/FilteringSelect widget.
This works perfect for me.
// sample code
function onTrigger(id){
var store = originalStore;
var request = store.fetch({query:{ID:id},
onComplete:onComplete});
}// create an empty datastore to save the query result and assign
// it to the filteringSelect element
function onComplete(items, request) {
var emptydata = {identifier: ‘ID’, items: []};
var tmpStore = new
dojo.data.ItemFileWriteStore({data:emptydata});for(var i = 0; i < items.length; i++){
tmpStore.newItem(…);// create new item
}
dijit.byId(“filteringSelect”).store = tmpStore;
}
------

一点看不明白~~~
Reply