0

我是 Extjs 的新手,使用 ExtJs 4.1.0,我制作了一个树形面板,其中的节点由 JSON 存储组成。很好,但是用户试图在按钮单击时显式添加/删除新记录(或节点),这从 json 响应文本中显示,数据被添加或删除,但它不会刷新树面板,请在这里帮助我。我尝试了许多方法,例如 tree.getStore.Load() 或 treepanel.root.reload(); 等没有任何作用,并将错误设为空。

    function MakeTreePanel(_store) {
    LeftPlanObjectenPanel = Ext.create('Ext.tree.Panel', {
        store: _store,
        id: 'mytree',
        autoShow: true,
        //height: 500,
        rootVisible: false,
        clearOnLoad: true,
        border: false,
        renderTo: Ext.getBody()
//        listeners: {
//            itemclick: function (view, record, item, index, e) {
//                fnClickLeaf(record.raw.id);
//                //alert(record.raw.id);
//            }
//        }
    });
}

我的店铺是这样的:

PlanObjectenStore = Ext.create('Ext.data.TreeStore', {
    autoLoad: true,
    autoSync: true,
    root: {
        expanded: true
    }
});

Ext.Ajax.request({
    url: 'DS_PlanObject.asmx/GetPlanObjectsByMindplanInJSON',
    timeout: ExtTimeoutVar,
    method: 'POST',
    headers: { 'Content-Type': 'application/json;charset=utf-8' },
    jsonData: { DecisionType: DecisionType, DecisionNumber: DecisionNumber, DecisionTypeNumber: DecisionTypeNo, MindPlanID: MindPlanID },
    success: function (result, request) {
        //alert("Response: " + result.responseText);
        PlanObjectJsonCollectionData = Ext.decode(result.responseText);
        if (LeftPlanObjectenPanel == null) {
            PlanObjectenStore = eval('{' + PlanObjectJsonCollectionData.d[0].naam + '}');
            //PlanObjectenStore = eval('{Ext.create(\'Ext.data.TreeStore\', { root: { expanded: true, children: [{ text: "ABCD1234", expanded: true, id: "root", children: [{ text: "plangebied", expanded: true, id: "plangebied" }, { text: "ehs", expanded: true, id: "23" }, { text: "ehs text", expanded: true, id: "24" }, { text: "ehs water", expanded: true, id: "25" }, { text: "lkjlkj", expanded: true, id: "17" }, { text: "new praveen", expanded: true, id: "19" }, { text: "nitin kumar soni", expanded: true, id: "22" }, { text: "nitin soni", expanded: true, id: "20" }, { text: "pks", expanded: true, id: "12" }, { text: "test another", expanded: true, id: "18" }, { text: "test praveen", expanded: true, id: "8" }, { text: "Test1", expanded: true, id: "1" }, { text: "Test2", expanded: true, id: "2" }, { text: "Test3", expanded: true, id: "3" }, { text: "Test4", expanded: true, id: "4" }, { text: "Test5", expanded: true, id: "5" }, { text: "Test6", expanded: true, id: "6" }, { text: "testkees", expanded: true, id: "7" }, { text: "vcvc", expanded: true, id: "15" }, { text: "yes sharma ji", expanded: true, id: "11"}]}]} });}');
            MakeTreePanel(PlanObjectenStore);
        }
    },
    failure: function (result, request) {
        alert('error:LoadTree method' + result.responseText);
        var jsonData = Ext.decode(result.responseText);
        myMask.hide();
    }
});

On Saving record in table: I use to call like this:
LeftPlanObjectenPanel.root.reload();

请让我知道如何重新加载我的树面板。谢谢

4

1 回答 1

0

通常,我们可以使用:

treeStore.getRootNode().appendChild(...);

示例

var decodedData = Ext.JSON.decode(data);
treeStore.getRootNode().appendChild(decodedData);
于 2013-05-29T09:52:36.740 回答