xiaoyao8810205 2011-12-08 00:38
浏览 494
已采纳

Extjs4.x ,tree.getStore().load(); 重复加载多次的问题,

使用 tree.getStore().load() 时,虽然最后都重新加载了,但居然会访问服务器十多次,这可如何是好?

关键自带如下:
[code="js"]
var store = Ext.create('Ext.data.TreeStore', {
fields:[{name:"url",type:"string"},{name:"pids",type:"string"},{name:"text",type:"string"}],
root: {
expanded:true,
text:"Root",
id:"0",
pids:"0,"
} ,
proxy: {
type: 'ajax',
url: '/getMenuData',
extraParams: {"test": "1"},
method: "POST",
reader: {
type: 'json'
}
},
autoLoad: true
});

var tree = Ext.create('Ext.tree.Panel', {
layout:'fit',
width: 200,
bodyPadding: 5,
store: store,
autoDestroy:true,
rootVisible:true,
title:"测试"
});

[/code]

,使用 tree.getStore().load()方法的时候,
怎么会重复加载多次?
怎么会这样?

  • 写回答

7条回答 默认 最新

  • nailuo87 2011-12-10 22:32
    关注

    贴上去 就解决了

    /*
    Overrides for fixing clearOnLoad for TreeStore
    */
    Ext.override(Ext.data.TreeStore, {
    load: function(options) {
    options = options || {};
    options.params = options.params || {};

    var me = this,
    node = options.node || me.tree.getRootNode(),
    root;

    // If there is not a node it means the user hasnt defined a rootnode yet. In this case lets just
    // create one for them.
    if (!node) {
    node = me.setRootNode({
    expanded: true
    });
    }

    if (me.clearOnLoad) {
    node.removeAll(false);
    }

    Ext.applyIf(options, {
    node: node
    });
    options.params[me.nodeParam] = node ? node.getId() : 'root';

    if (node) {
    node.set('loading', true);
    }

    return me.callParent([options]);
    }
    });

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝