我有树店。
var store = Ext.create('Ext.data.TreeStore', {
root: {
autoLoad:false,
expanded: false,
children: [
{
id:"0", text: "School Friends", expanded: true, children:
[
{
id:"1", text: "Mike", leaf: true, name: "Mike", email: "mike@stackoverflow.com", phone: "345-2222"
},
{
id:"select", text: "Laura", leaf: true, name: "Laura", email: "laura@stackoverflow.com", phone: "345-3333"
}
]
}
]
}
});
和树面板。
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
listeners:{
afterrender:function(){
var record = this.getStore().getNodeById('1');
this.getSelectionModel().select(record)
}
}
});
一切正常! 但是当我改变商店时,使用代理请求。选择无效*
var storeTree = Ext.create('Ext.data.TreeStore', {
autoLoad:true,
expanded: true,
proxy: {
type: 'ajax',
url: 'tree.json',
},
root: {
text: 'Ext JS',
id: 'src',
expanded: true,
// children:[]
},
folderSort: true,
sorters: [{
property: 'text',
direction: 'ASC'
}]
});
我使用相同的 JSON
[
{"id":4, "text":"second",},
{
id:"0", text: "School Friends", expanded: true, children:
[
{
id:"1", text: "Mike", leaf: true, name: "Mike", email: "mike@stackoverflow.com", phone: "345-2222"
},
{
id:"select", text: "Laura", leaf: true, name: "Laura", email: "laura@stackoverflow.com", phone: "345-3333"
}
]
},
]