【问题标题】:extjs refresh tree storeextjs 刷新树存储
【发布时间】:2012-05-19 08:38:04
【问题描述】:

如何刷新树形存储?

我试图这样做:

Ext.getStore('myStore').setRootNode({child: []});

然后商店会要求服务器生孩子,但有时它会给我一个双胞胎。 在我的树中,我得到类似的东西:

child1
child2
child1

还有一个javascript错误:

Uncaught TypeError: Cannot read property 'internalId' of undefined
Ext.define.updateIndexes ext-all-debug.js:61588
Ext.define.onAdd ext-all-debug.js:61513
Base.implement.callParent ext-all-debug.js:3728

这是一个错误还是我做错了什么?

【问题讨论】:

    标签: extjs tree store


    【解决方案1】:

    我不确定你使用的是哪个版本的 extjs,但这是我在 4.1 中使用 load 方法刷新我的商店的方法(你可能有也可能没有参数,我有一个):

    this.getStore('MyTreeStore').load({ params: { id: this.getId().getValue()} });
    

    使用新记录刷新存储,之前任何加载都没有重复记录。

    我的商店设置如下:

    Ext.define('MyApp.store.MyTreeStore', {
        extend: 'Ext.data.TreeStore',
        model: 'MyApp.model.MyTreeModel',
    
        root: {
              children: []
        },
    
        proxy: {
            type: 'ajax',
            url: '/MyApp/Chart/GetTree'
        },
        fields: [
             { name: 'id', type: 'int' }
        ]
    });
    

    我的树看起来像这样:

    Ext.define('MyApp.view.chart.MyTree', {
        extend: 'Ext.tree.Panel',
        alias: 'widget.mytree',
    
        id: 'MyTree',
        store: 'MyTreeStore',
        width: 350,
        height: 320,
        border: false,
        rootVisible: false,
        singleExpand: true
    });
    

    【讨论】:

    • 谢谢我解决了这个问题,我做了两次非常关闭的刷新。这就是为什么我得到了一些双打。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 2011-11-30
    • 2012-05-26
    • 1970-01-01
    • 2011-12-03
    • 2013-05-24
    • 1970-01-01
    相关资源
    最近更新 更多