方式1:
如果返回的数据是TreeSore标准格式。
{
"text": "Ext",
"expanded": true,
"children": [
{
"text": "TIP",
"iconCls": "x-fa fa-leanpub",
"expanded": true,
"selectable": false,
"children": []
}
]
}
不需要使用reader既可以。
proxy: {
type: 'ajax',
url: '/app/data/NavigationTree.json'
}
方式2:
但是,如果返回数据不是TreeSore标准格式:
{
"text": "Ext",
"expanded": true,
"items": [
{
"text": "TIP",
"iconCls": "x-fa fa-leanpub",
"expanded": true,
"selectable": false,
"children": []
}
]
}
使用reader解析返回数据的话, 则每个节点点击的时候都会去后端请求根据当前的节点获取其子节点, 如果后端方法没有处理的话, 则循环得到当前的节点。
reader: {
type: 'json',
rootProperty: 'items'
}
方式1:适合一次加载树的所有数据, 数据量较小的状况。
方式2:适合每个树的子节点都需要从后端获取, 数据量较大的状况。