javascript 如何禁用“dijit.form.FilteringSelect”小部件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11909075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:44:02  来源:igfitidea点击:

How to disable a "dijit.form.FilteringSelect" widget?

javascripthtmldojo

提问by Dreamer

I cannot find a way to disable the dijit.form.FilteringSelect widget. The requirement makes the css display as none is not an option.

我找不到禁用 dijit.form.FilteringSelect 小部件的方法。该要求使 css 显示为 none 不是一个选项。

Any hint? Thanks in advance.

任何提示?提前致谢。

回答by Dreamer

Figure it out myself:

自己想办法:

dijit.byId('_fromState_id').set('disabled', true);

simply does the job. Change it to falsecan enable the widget.

只是做的工作。将其更改为false可以启用小部件。

Cheers.

干杯。

UPDATE

更新

Plus, there is another attribute to the widget called "readOnly", the difference from it and "disabled"is that :

另外,小部件还有另一个属性叫做"readOnly",与它的区别"disabled"在于:

  1. disableddoes not allow any value given to the widget, meaning the widget value is always NULL("")in the form. It might be a problem in NotNullsituation;

  2. but readOnlyallows to preset a value to the widget and make it not editable, and user can still submit the value just only not able to change it.

  1. disabled不允许为小部件提供任何值,这意味着小部件值始终NULL("")在表单中。NotNull情况可能有问题;

  2. readOnly允许为小部件预设一个值并使其不可编辑,并且用户仍然可以提交该值,只是无法更改它。

sample:

样本:

  dijit.byId("_fromState_id").set("value", "NOTAVAILABLE");
  dijit.byId('_fromState_id').set('readOnly', true);