我有一Ext.grid.Panel
组列.此网格已过滤,根据过滤器,我想为列定义编辑器.
我的网格:
Ext.define('Mb.view.MyPanel', { extend: 'Ext.grid.Panel', columns: [ {text: 'Order #', dataIndex: 'id'}, {text: 'Action', dataIndex: 'type', renderer: function(value){ if(value == 'BP') return Lang._('Veuillez choisir') return '' } },
现在我想做一些事情:
var panel = Mb.app.getView('MyPanel'); if (condition == true) { panel.getColumns[1].setEditor({ xtype: 'textfield', ... }) }
显然,方法getColumns
和setEditor
不存在.因此,我需要另一种方法来激活该列上的编辑器.
我没有找到一种方法来访问列定义来修改它们并在之后重新呈现网格.
你能给我一个关于搜索方向的提示吗?谢谢.
检查出的文档getEditor()
上Ext.grid.column.Column
.如果您使用的是编辑插件,该插件可以提供实现getEditor()
,以及setEditor()
.根据正在编辑的列和您实现的任何自定义逻辑,您可以实现一个自定义getEditor()
方法,根据具体情况返回您想要的任何编辑器实例.
文件说:
getEditor( record, defaultField ) : Ext.form.field.Field
这真的说明了一小部分真相.
getEditor
不仅是一种方法Ext.grid.column.Column
,也是一种配置选项.
如果getEditor
定义为配置选项函数,则调用get getEditor( record )
并需要返回a Ext.grid.CellEditor
.
这将适用于cellediting插件,但不适用于rowediting插件.
以下是列配置的示例.它将仅在选定的行上创建组合框:
columns: [{ text: 'Action', dataIndex: 'action', getEditor: function(record){ if( my logic ){ return Ext.create('Ext.grid.CellEditor', { field: Ext.create( 'Ext.form.field.ComboBox', { forceSelection: true, store: [[1, 'Option 1'], [2, 'Option 2']] }) }) } else return false; } },