EXTJS4.1:TreePanel和单元格编辑(单元格编辑插件的意外行为)

EXTJS4.1:TreePanel和单元格编辑(单元格编辑插件的意外行为),extjs,extjs4,extjs4.1,Extjs,Extjs4,Extjs4.1,我有一个树面板,有两列“Tree”和“Description” 我从树存储中渲染树和描述列,使用CellEditing插件使描述列可编辑 编辑“描述”列下的任何单元格时,其对应树节点的名称将更改为第一个树节点的名称 这是我的密码 var store = Ext.create('Ext.data.TreeStore',{ autoLoad : false, autoSync : true, proxy : { type :

我有一个树面板,有两列“Tree”和“Description”

我从树存储中渲染树和描述列,使用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()

});
我还重写了AbstractStore的indexOf配置,我在中将其视为bug

在编辑任何其他列数据时,我不希望更改树节点名称。
非常感谢您的帮助。提前感谢。

我观察到,每次我编辑“Description”列(可编辑)下的任何单元格时,相应的treecolumn会再次加载整个树,实际上它会重新加载tree.json.Ohhh。。。最后我发现了问题。它是store的自动同步变量。它必须为false,否则每次编辑单元格时,都会向存储区发出同步请求。
{
    "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" : ""
        }
    ]
}