EditorGridPanel中 根据行记录的值决定某行或者某行中的哪些列是否可以编辑
参考源码,覆盖 isCellEditable 方法,如:
参考源码,覆盖 isCellEditable 方法,如:
cm = new Ext.grid.ColumnModel({
columns : [new Ext.grid.RowNumberer(), {
header : '备注',
width : 600,
sortable : true,
dataIndex : 'remark'
}, {
header : '值',
width : 150,
sortable : true,
dataIndex : 'value',
editable : true,// 必须默认为true,否则 isCellEditable 没法用
editor : new Ext.form.TextField({
allowBlank : true,
blankText : '',
selectOnFocus : true,
maxLength : 200
})
}],
/* 覆盖默认的方法,根据record条件决定是否可以编辑 */
isCellEditable : function(col, row) {
var rec = _this_store.getAt(row);
// var columnIndex =
// this.findColumnIndex('userName');//可以获得指定名称的列的index
if (rec.data.canEdit != 1) {
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable
.call(this, col, row);
}
});
本文介绍如何使用ExtJS中的EditorGridPanel组件,并通过覆盖isCellEditable方法实现对表格中特定行或列的编辑权限控制。具体操作涉及设置ColumnModel及判断record属性来达到目的。

被折叠的 条评论
为什么被折叠?



