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

时间:2012-07-30 15:16:33

标签: extjs extjs4 extjs4.1

我有一个树面板,有两列“树”和“描述”。

我从TreeStore渲染树和描述列,使用CellEditing插件使Description列可编辑。

当我编辑Description列下的任何单元格时,其对应的Tree节点名称将更改为第一个树节点名称的名称。

这是我的代码,

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中看到了错误

我不想更改树节点名称,因为我编辑任何其他列数据。 帮助将非常感激。提前谢谢。

0 个答案:

没有答案