[dojo] Related Selection

February 12th, 2008

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;
}

[Post to Twitter]  [Post to Plurk]  [Post to Delicious]  [Post to Digg]  [Post to Facebook]  [Post to MySpace]  [Post to Ping.fm] 



------

One Response to “[dojo] Related Selection”


  1. Jay said:

    一点看不明白~~~ :shock:

    Reply

required
required

Top

Tweet This Post links powered by Tweet This v1.4.1, a WordPress plugin for Twitter.