Ext4.1如何禁止对某些单元格进行编辑
Ext4.1如何禁止对某列进行编辑,或者对一些特殊的单元格不允许进行编辑
可以通过beforeedit事件对单元格进行判断,不符合编辑的单元格单击编辑时return false阻止生成输入控件。
Ext4.1 Ext.grid.PanelView事件的介绍如下
beforeedit( editor, e, eOpts ):Forwarded event from Ext.grid.plugin.Editing.
Fires before editing is triggered. Return false from event handler to stop the editing.
Available since: Ext 4.1.0
Parameters
- editor : Ext.grid.plugin.Editing
- e : Object
An edit event with the following properties:
- grid - The grid
- record - The record being edited
- field - The field name being edited
- value - The value for the field being edited.
- row - The grid table row
- column - The grid Column defining the column that is being edited.
- rowIdx - The row index that is being edited
- colIdx - The column index that is being edited
- cancel - Set this to true to cancel the edit or return false from your handler.
- originalValue - Alias for value (only when using CellEditing).
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
通过上面的介绍我们可以通过参数e来得到要编辑的列名称,值,所在行号,列号之类的信息,通过组合判断这些信息就可以实现那些单元格不能编辑了。
如下面的demo是不能编辑common这个字段。
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); // create the grid and specify what field you want // to use for the editor at each header. var grid = Ext.create('Ext.grid.Panel', { //....其他配置 listeners: { beforeedit: function (editor, e, eOpts) { if (e.field == 'common') return false; return true; } }, plugins: [cellEditing] });
加支付宝好友偷能量挖...
原创文章,转载请注明出处:Ext4.1如何禁止对某些单元格进行编辑