I have a dijit.form.FilteringSelect
component and I want to change the options dynamically. But I get the store from the dijit.form.FilteringSelectwith its store property; there is no setter function in the store. (It may be a dojo.store.Reader)
So how can I change the option of dijit.form.FilteringSelect
? Should I change it directly with DOM? Is there any way to update the store behind dijit.form.FilteringSelect
?
the properties 'urlPreventCache:true, clearOnClose:true' will force the store to be reloaded
and then, on event/callback/handler where you need/want to reset the values just do this
there is two type of data store in dojo:
dojo.data.ItemFileWriteStore - extension of ItemFileReadStore that adds on the dojo.data.api.Write
In your case, you should use ItemFileWriteStore - it provides functions for modifying data in store.
E.g.:
You have array of countries and you want to use it in filtering select:
First of all you will need to create data store js-variable for ItemFileWriteStore.
Next step - declare filtering select and itemFileWriteStore in html markup:
And finally create special functions for add/delete/modify items in filtering select:
Add New Item:
I hope here is all clear. Only small note: "identifier" field ("abbr" in our case) must be unique in store
Delete Items - e.g. removing all items with name "United States of America"
As you can see i have created query, that finds items with name == "United States of America" in data store. After the query is executed, function "gotNames" will be called. function gotNames removes all items that query return.
And last function - Edit Item
it is similar to the delete function. only one difference:
you should use
setValue()
method of itemFileWriteStore for changing item property:Here - page with working example
I solved the same problem with this sentences, hope it helps someone.
For Dojo version < 1.7
For Dojo version >= 1.7
To change displayed text (current selected)
You can see this properties using Firebug or another debug console.