Dojo 1.9: Dijit: Disabling option items in a dijit/Form/FilteringSelect that was populated using a store

混江龙づ霸主 提交于 2019-12-01 10:49:41

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.

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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!