ExtJS filefield设置disabled为true后按钮不灰显的解决办法
2014-07-30 14:42
330 查看
ExtJS4.1中,filefield设置默认值为true时,按钮是灰显的,但是如果调用setDisabled来设定的时候,发现浏览按钮不会灰显,但是的确是被禁用了。如何解决了,只能从源码入手了。原来源码中并没有主动对浏览按钮加上灰显的样式,只是当默认值为true时才会加。因此我们需要在源码中手动加上css样式。
默认源码如下:
修改方法及修改后的源码如下:
经过修改后,测试截图如下。
正常
禁用后
启用后
默认源码如下:
disableItems: function(){ var file = this.fileInputEl; if (file) { file.dom.disabled = true; } this['buttonEl-btnEl'].dom.disabled = true; }, onEnable: function(){ var me = this; me.callParent(); me.fileInputEl.dom.disabled = false; this['buttonEl-btnEl'].dom.disabled = true; },
修改方法及修改后的源码如下:
Ext.override(Ext.form.field.File,{ disableItems: function(){ var file = this.fileInputEl; if (file) { file.dom.disabled = true; } this['buttonEl'].addCls('x-btn-disabled'); this['buttonEl-btnEl'].dom.disabled = true; }, onEnable: function(){ var me = this; me.callParent(); me.fileInputEl.dom.disabled = false; this['buttonEl'].removeCls('x-btn-disabled'); this['buttonEl-btnEl'].dom.disabled = true; } });
经过修改后,测试截图如下。
正常
禁用后
启用后
相关文章推荐
- 在Ext(Version2.2 和目前的Version3.1.1 Version3.2) 里面存在一个BUG,就是当设置了 stripeRows:true, 并没有出现斑马线的效果,解决的办法是在定义一个css类,放置在一个独立的css文件里面,页面加以引用。
- EXTJS FORM textField emptyText 空值提交的解决办法
- 关于ExtJS中FormPanel中的timefield选中不显示的解决办法
- 【sqlldr】 “Field in data file exceeds maximum length ”解决办法
- WARN com.opensymphony.xwork2.ognl.OgnlValueStack异常的解决办法[提交按钮使用了图片并设置name属性,对应action无gettersetter]
- 解决this.disabled=true;不能执行服务器端代码的问题(点击后按钮变不可用状态)
- [转贴]【sqlldr】 “Field in data file exceeds maximum length ”解决办法
- Stuts2的"struts.devMode"设置成true后,不起作用的解决办法
- “textField.placeholder属性中的文字设置后在ios7下在textfield的中间。在ios6下字会往上偏”解决办法
- 在Closing事件中,将e.Cancle设置成true,则Windows无法关机和重启系统的解决办法
- FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法
- FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法
- 关于fedora 17启动时显示cannot open font file true的解决办法
- FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法【转】
- ExtJS中FormPanel设置FileUpload为true后,提交返回下载文件的解决
- 若碰到Directory.Delete("filePath",true)时,报“目录不是空的”的解决办法
- FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法
- asp.net中使用fckeditor时,提示“this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx”解决办法
- div设置contentEditable="true"作为文本编辑器,定位光标解决办法
- js和jquery设置disabled属性为true使按钮失效