sencha treestore 取消自动加载数据

gridstore在设置了autoLoad=false后不会自动加载数据,但是treestore不行,后来发现删掉root里的expanded:true后就可以了。但是界面上树没有展开,需在store的load回调里加上展开根节点的代码:tree.getRootNode().expand();

store定义:

Ext.define('portaltest3.store.OrgTreeStore', {
extend: 'Ext.data.TreeStore',

requires: [
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json',
'Ext.data.Field'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: false,
storeId: 'OrgTreeStore',
root: {
name: '根节点',
//expanded: true  //删掉
},
proxy: {
type: 'ajax',
extraParams: {},
url: 'DataService/Manage/Manage.ashx',
reader: {
type: 'json'
}
},
fields: [
{
name: 'Name'
},
{
name: 'Id'
}
]
}, cfg)]);
}
});

From:http://www.cnblogs.com/xuejianxiyang/p/5284222.html

原文地址:https://www.cnblogs.com/xuejianxiyang/p/5284222.html