Skip to content Skip to sidebar Skip to footer

Dojo 1.9: Dijit: Disabling Option Items In A Dijit/form/filteringselect That Was Populated Using A Store

I am trying to disable option items in a dijit/Form/FilteringSelect control that is populated using a store. Following this guide: http://dojotoolkit.org/documentation/tutorials/1.

Solution 1:

There is a difference between the data in your store (which is in fact the business data) and your rendered data (containing view logic). If you use a store, you're actually feeding your rendered data with your store.

To alter the rendered data (= the options in your select), you need to use the getOptions(idx) method of the dijit/form/Select as you can read in the API documentation. To alter the disabled state of the option you can use:

registry.byId("mySelect").getOptions(myId).disabled = true;

That's all you need. Changing the store data won't help, since it represents business data, not view data. I also made an example JSFiddle where the second option is disabled.

Solution 2:

for dojo 1.10 and upto 1.x latest version, you need to add a line of code to update the selection UI:

registry.byId("mySelect").getOptions(myId).disabled = true;
registry.byId("mySelect").updateOption(myId);

Post a Comment for "Dojo 1.9: Dijit: Disabling Option Items In A Dijit/form/filteringselect That Was Populated Using A Store"