Extjs grid单元格编辑,有一个字段【只读】readonly,设置xtype为checkcolumn,
但点击checkbox时状态切换有问题,只能把选中的改为不选中,不选中的却无法选中
var fieldCellEditing = Ext.create("PSI.UX.CellEditing", {
clicksToEdit: 1, //点击几次进入编辑模式
listeners: {
edit: {
fn: me.fieldCellEditingAfterEdit,
scope: me
}
}
});
me.__FieldGrid = Ext.create("Ext.grid.Panel", {
viewConfig: {
enableTextSelection: true
},
title: '显示字段配置',
border: 1,
selModel: Ext.create('Ext.selection.CheckboxModel', {}),
columnLines: true,
plugins: [
fieldCellEditing
],
columns: [{
xtype: "rownumberer",
width: 40
}, {
header: "字段",
dataIndex: "field_name",
menuDisabled: true,
sortable: true,
editor: {
allowBlank: false
},
width: 140
}, {
header: "字段标题",
dataIndex: "field_caption",
menuDisabled: true,
sortable: true,
editor: {
allowBlank: false
},
width: 120
}, {
header: "只读",
dataIndex: "readonly",
menuDisabled: true,
sortable: true,
align: 'center',
xtype: 'checkcolumn'
}
...
原来是字段定义这里的问题:
Ext.define(modelName, {
extend: "Ext.data.Model",
fields: [
{name: "field_name", type: 'string'},
{name: "field_caption", type: 'string'},
{name: "readonly", type: 'number'},
]
});
要把readonly的type从number改为bool
Ext.define(modelName, {
extend: "Ext.data.Model",
fields: [
{name: "field_name", type: 'string'},
{name: "field_caption", type: 'string'},
{name: "readonly", type: 'bool'},
]
});
这样就ok了