Dojo:如何禁用dijit.form.FilteringSelect选项 [英] Dojo: How to disable a dijit.form.FilteringSelect option

查看:311
本文介绍了Dojo:如何禁用dijit.form.FilteringSelect选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在dijit / Form / FilteringSelect中禁用选项。这里是代码

 < select id =filtSelectdojoType =dijit.form.FilteringSelect> 
< option disabled =disabled>选择< / option>
< option value =1>一个< / option>
< option value =2>两个< / option>
< option value =3>三< / option>
< / select>

请帮助我。

解决方案

正如其他人指出的那样,问题在于FilteringSelect依赖于dojo数据存储。所以如果你没有手动创建,它会发生在幕后,你只是不知道如何引用它。但是第二个想法是,看看API,我注意到FilteringSelect有一个名为store的属性。



所以,你需要自己创建数据存储和&用它初始化FilteringSelect( http://dojotoolkit.org/reference-guide /1.9/dijit/form/FilteringSelect.html )或通过使用dijit的byId然后访问store属性来检索它。

然后,操纵数据存储。如果您希望在恢复之后删除选项,可能会先存储临时副本。如果你查找数据存储,我确信删除一个选项是微不足道的。有时候使用小部件时,碰巧你需要触发一种重新渲染方法,以便在更新之后进行更新(通常可以在小部件的API中找到一些方法,有时会重置),尽管我相信商店可能会看到它们更智能。


I am trying to disable option items in a dijit/Form/FilteringSelect. Here is code

 <select id="filtSelect" dojoType="dijit.form.FilteringSelect">  
        <option disabled="disabled">Select</option>  
        <option value="1">One</option>  
        <option value="2">Two</option>  
        <option value="3">Three</option>  
  </select>

Please help me.

解决方案

The issue is that FilteringSelect relies on dojo data store, as others have pointed out. So if you don't create that manually, it will happen behind the scenes and you just won't know how to reference it. But on second thought, looking at the API I notice FilteringSelect has a property named store.

So, you either need to create the data store yourself & initialize the FilteringSelect with it (http://dojotoolkit.org/reference-guide/1.9/dijit/form/FilteringSelect.html) or retrieve it by using dijit's byId and then accessing the "store" property.

Then, manipulate that data store. Maybe store a temporary copy before you remove the option if you want to restore it after. If you look up data store I'm sure removing an option is trivial. Sometimes with widgets it happens that you need to trigger a re-rendering method also to have it update after (you can usually find some method in the widget's API for this, sometimes "reset"), though I believe with stores it may watch them more intelligently.

这篇关于Dojo:如何禁用dijit.form.FilteringSelect选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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