我有一个包含两列“树”和“描述”的树面板。
我从 TreeStore 渲染树和描述列,使用 CellEditing 插件使描述列可编辑。
当我编辑描述列下的任何单元格时,其对应的树节点的名称更改为第一个树节点的名称。
这是我的代码,
var store = Ext.create('Ext.data.TreeStore',{
autoLoad : false,
autoSync : true,
proxy : {
type : 'ajax',
url : 'data/tree.json',
},
fields: [
{name: 'optionName', type: 'string'}, {name: 'description', type: 'string'}
]
}
);
Ext.override(Ext.data.AbstractStore,{
indexOf: Ext.emptyFn
});
Ext.define('AEV.view.TreePanel', {
extend: 'Ext.tree.Panel',
title: 'Simple Tree',
width: 700,
height: 400,
store: store,
rootVisible: false,
disableSelection:true,
viewConfig : {
emptyText : '<center><span class="empty-table">No data!</span></center>',
singleSelect : true,
stripeRows : true
},
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit:1
})
],
columns:[
{
xtype: 'treecolumn',
text: 'Tree',
dataIndex: 'optionName',
flex: 1,
sortable: false
},
{
text: 'Description',
dataIndex: 'description',
flex: 2,
sortable: false,
editor: {
xtype: 'textfield',
allowBlank: true
}
}
],
renderTo: Ext.getBody()
});
我的 tree.json 是
{
"children": [
{
"optionName": "ABC",
"expanded": true,
checked: true,
"children": [
{
"optionName": "DEF",
checked: true,
"leaf": true,
"description" : ""
},
{
"optionName": "GHI",
checked: true,
"leaf": true,
"description" : ""
}
], "description" : ""
},
{
"optionName": "JKL",
"expanded": true,
checked: true,
"children": [
{
"optionName": "MNO",
checked: true,
"leaf": true,
"description" : ""
}
],
"description" : ""
},
{
"optionName": "PQR",
checked: true,
"expanded": true,
"children": [
{
"optionName": "STU",
checked: true,
"expanded": true,
"children": [
{
"optionName": "VW",
checked: true,
"leaf": true,
"description" : ""
},
{
"optionName": "XYZ",
checked: true,
"leaf": true,
"description" : ""
}
],
"description" : ""
}
],
"description" : ""
}
]
}
我还覆盖了 AbstractStore 的 indexOf 配置,我在http://www.sencha.com/forum/showthread.php?131602-4.0.0-Cellediting-on-TreeGrid中将其视为错误
我不希望树节点名称更改,因为我编辑任何其他列数据。帮助将不胜感激。提前致谢。