treestore を含むツリーは最初にロードされますが、子ノードの要求に失敗します。
子を要求するlocalpath
と、子データが配置されているパスを定義するパラメーターが送信されます。
初期化要求: localpath=/
-> すべての子を取得します/
子リクエスト: localpath=/subfolder1
-> すべての子を取得します/subfolder1
初期ロードを示すスクリーンショットと、フォルダーがクリックされたときのスクリーンショットを 2 つ添付しました。
ところで: 矢は私のツリーのどこに消えたのですか?
Json : 私のツリー ストアは、次のような json データを受け取ります。
{
"value": {
"name": "",
"path": "/",
"leaf": false,
"type": "folder",
"children": [
{
"name": "subfolder1",
"path": "/subfolder1",
"leaf": false,
"type": "folder",
"children": []
},
{
"name": "subfolder2",
"path": "/subfolder2",
"leaf": false,
"type": "folder",
"children": []
},
{
"name": "testreports",
"path": "/testreports",
"leaf": false,
"type": "folder",
"children": []
}
]
}
}
Store : ツリー ストアは次のようになります。
var oTreeStore = Ext.create( 'X.module.store.store.Tree', {
model : 'X.module.store.model.TreeNode',
api : this.httpApi,
module : "store",
func : "getchildren",
scope : "user"
} );
TreePanelの作成:
var oTreePanel = Ext.create( 'X.module.store.view.TreePanel', {
store : oTreeStore
} );
ツリーパネルの定義:
constructor: function( oConfig ) {
var self = this;
//creating a proxy, which can communicate with HTTP-API
//and is able to parse it's json-tree format
var oProxy = Ext.create( 'X.lib.httpapiclient.Proxy', {
api : oConfig.api,
module : oConfig.module,
func : oConfig.func,
params : {
scope : oConfig.scope
},
reader : {
type: 'json',
root: function( o ) { return o.value? o.value.children : o.children; }
},
delay : oConfig.delay || 100,
success : oConfig.success || function() {},
progress: oConfig.progress || function() {},
error : oConfig.error || function() {}
} );
oConfig.nodeParam = 'localpath';
oConfig.proxy = oProxy;
self.callParent( arguments );
//the HTTP-API requires the ID of the root-node to be empty
self.on( 'beforeload', function( s, o ) {
if( o.params.localpath === 'root' ) o.params.localpath = '/';
} );
}
モデル: モデル...
Ext.define( 'X.module.store.model.TreeNode', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name', type: 'string' },
{ name: 'path', type: 'string' },
{ name: 'type', type: 'string' }
]
} );