ExtJS 4>行编辑器网格>如何更改“更新”按钮文字
有没有办法更改 ExtJS-4 行编辑器网格中“更新”按钮的文本?
Is there any way to change the text of "Update" button in ExtJS-4 Row Editor Grid ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好问题,我查看了源代码,虽然 RowEditing 插件中没有任何内容,但在它扩展“RowEditor.js”的类中,有以下内容:
所以我假设您只需要覆盖 < code>'saveBtnText' 在
'Ext.grid.plugin.RowEditing'
实例中,因为它使用 callParent(arguments) 调用父构造函数RowEditing
类Good question, I had a look through the source code and whilst there is nothing inside the RowEditing plugin, in the class it extends 'RowEditor.js' there is the following:
So I'd assume you'd just need to override the
'saveBtnText'
in your instance of'Ext.grid.plugin.RowEditing'
as it calls the parent constructor with callParent(arguments) in theRowEditing
class没那么容易,而且没有在无证区域进行黑客攻击。问题是,
Ext.grid.plugin.RowEditing
直接实例化Ext.grid.RowEditor
,而不允许您传入配置选项。因此,一般来说,您必须重写插件中的initEditor()
方法并实例化您自己的行编辑器:Not that easy and not without hacking in undocumented areas. The problem is, that the
Ext.grid.plugin.RowEditing
directly instantiates theExt.grid.RowEditor
without allowing you to pass in configuration options. So in general you have to override theinitEditor()
method in the plugin and instantiate your own row editor:对于 ExtJS 4
For ExtJS 4
这个解决方案是定义rowEditors的原型。这意味着这个配置比较一般。
如果您只想为一个编辑器更改它,或者如果您想获得不同的配置,那么原型绝对不是解决方案。
查看源代码:
此方法初始化 rowEditor,并且 btns 数组上有一个循环:
btns 数组:
在这个循环中,对于 btnArray 中的每个字符串,将搜索 cfg 中是否存在相同的字符串属性,如果找到,则将其添加到配置中。您只需管理该循环找到您想要修改的内容:
示例:我们想要更改保存按钮的文本:
作为 btns 数组的第一项的属性 saveBtnText 必须存在于 cfg 中:
如果属性存在,则进行此搜索:< code>if (Ext.isDefined(me[item]))
如果 saveBtnText 已存在于 rowEditor 属性中,则:
并且将设置附加配置属性!
This solution is to define the prototype of rowEditors. that means that this config is than general.
If you want to change it just for one editor, or if you want to get different configs , the prototype is definitely not the solution.
look at source code :
this method inits the rowEditor, and there's a loop on btns Array:
btns Array :
In this loop foreach string in btnArray it's searched if exists in cfg the same string property, if it's found it's added to config. You just have to manage that this loop finds what you want to modify:
Example: we want to change the text of save button:
the property saveBtnText which is the first item of btns Array must exists in cfg:
this search if property exists :
if (Ext.isDefined(me[item]))
if saveBtnText already exists in rowEditor properties then:
and the additional config property will be set!!