我被困在創建一個樹面板的例子。我只獲得一棵無限樹。我做錯了什麼?ExtJs 4.2 treepanel
模型
Ext.define('mdlDocumentosTree', {
extend: 'Ext.data.Model',
fields:[
{name:'id', type:'string', mapping:''},
{name:'text', type:'string', mapping:''},
{name:'leaf', type:'boolean', mapping:''},
{name:'iconCls', type:'string', mapping:''}
]
});
STORE
Ext.define('strDocumentosTree', {
extend: 'Ext.data.TreeStore',
model: 'mdlDocumentosTree',
autoLoad: false,
proxy: {
type: 'ajax',
api: {read: 'some url'},
reader: {
type: 'json',
root: 'data',
totalProperty: 'total',
successProperty: 'success'
}
}
});
VIEW
var arbolcarpetas=new Ext.tree.Panel({
itemId:'arbolcarpetas',
title:'Archivos del Expediente',
region:'west',
width:250,
collapsible:true,
border: false,
autoScroll:true,
store:almacenDocumentos,
rootVisible: false
})
CONTROLLER
在控制器我加載樹存儲與此命令:
Ext.ComponentQuery.query('viewFichaDetalle #arbolcarpetas')[0].getStore().load();
和店鋪的PHP是:
<?php
$x=0;
$nodes = array();
while($x<10){
array_push($nodes,array('text'=>"A".$x, 'id'=>$x,'children'=>array('text'=>"A".rand(10,100),'id'=>$x,leaf=>true,'iconCls'=>'icon-excel')));
$x++;
}
echo json_encode($nodes);
?>
結果是這樣的無限樹:
什麼是我做錯了嗎?任何線索?
你可以請一把小提琴嗎?當你這樣做時,請檢查問題是否你的模型不是來自['Ext.data.TreeModel'](http://docs.sencha.com/extjs/4.2.2/#!/api/Ext .data.TreeModel)。 – Alexander
在你的PHP代碼中,你想達到什麼目的?因爲,在ExtJS代碼中沒有什麼問題,當我在樹中展開一個節點時,商店URL將會被擊中,php代碼將會執行並返回相同的一組節點。 – Saloo
你是否也可以發佈你的回覆數據? –