Dojo 1.9:Dijit:禁用使用存储区填充的dijit / Form / FilteringSelect中的选项项 [英] Dojo 1.9: Dijit: Disabling option items in a dijit/Form/FilteringSelect that was populated using a store

查看:90
本文介绍了Dojo 1.9:Dijit:禁用使用存储区填充的dijit / Form / FilteringSelect中的选项项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图禁用使用商店填充的dijit / Form / FilteringSelect控件中的选项。

I am trying to disable option items in a dijit/Form/FilteringSelect control that is populated using a store.

遵循本指南: http://dojotoolkit.org/documentation/tutorials/1.9/ selection_using_stores /

只有选择控件是在没有使用商店创建的情况下才可能的。我从调试FilteringSelect例子推断出来。我尝试了两种方法来禁用一个项目:

It seems to be only possible if the Select control was created without using a store. I have deduced this from debugging the FilteringSelect example. I have tried two methods to disable an item:


  1. 按照这个线程的建议:如何在dijit.form.Select中禁用单个选项? 。但是,FilteringSelect示例中的stateStore存储对象没有options属性。

  1. Following the advice in this thread: How to disable a single option in a dijit.form.Select?. However, the "stateStore" store object in the FilteringSelect example does not have an 'options' property.

尝试访问存储对象中的相应元素。例如,在FilteringSelect示例中,我执行以下操作:

Attempting to access the appropriate element in the store object. For example, in the FilteringSelect example, I do the following:

var optionItem = stateStore.get("AZ");
optionItem.disabled = true;
stateStore.put(optionItem);
select.startup();


这两种方法似乎都不起作用,所以似乎在Dijit Select控件中禁用项目的唯一方法是使用选项属性。
提前感谢一个解决方案!

Neither method seems to work, so it seems that the only way to have disabled items in Dijit Select controls is to use the options property instead. Thanks in advance for a solution!

推荐答案

您商店中的数据有区别事实上业务数据)和您呈现的数据(包含视图逻辑)。如果您使用商店,您实际上会将您提供的数据与您的商店进行交流。

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.

要更改呈现的数据(=选择中的选项),您需要使用 dijit / form / Select getOptions(idx)方法,您可以在 API文档。要更改您可以使用的选项的禁用状态:

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;

这就是你需要的。更改商店数据将无法帮助,因为它代表业务数据,而不是查看数据。我也举了一个例子: JSFiddle ,其中第二个选项被禁用。

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.

这篇关于Dojo 1.9:Dijit:禁用使用存储区填充的dijit / Form / FilteringSelect中的选项项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆