extjs刷新树存储 [英] extjs refresh tree store

查看:98
本文介绍了extjs刷新树存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何刷新树存储?

我试图这样做:

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

然后,商店将请求服务器生子,但有时它会给我生双子. 在我的树中,我得到类似的东西:

And then the Store will request the Server to have children but sometimes it gives me a child in double. In my Tree I get something like:

child1
child2
child1

,还有一个JavaScript错误:

and there is also a javascript error:

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

是错误还是我做错了什么?

Is it a bug or am I doing something wrong ?

推荐答案

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

I'm not sure what version of extjs you're using but here's how I refresh my store in 4.1 using the load method (you may or may not have parameters, I have one):

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

使用新记录刷新商店,其中没有任何先前加载的重复记录.

The store is refreshed with new records with no duplicates from any previous load.

我的商店设置如下:

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
});

这篇关于extjs刷新树存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆