【发布时间】:2016-09-05 16:06:14
【问题描述】:
我无法创建树面板的示例。我只获得了一个无限的树。我做错了什么?
型号
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:''}
]
});
商店
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'
}
}
});
查看
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
})
控制器
在控制器中,我使用以下命令加载树存储:
Ext.ComponentQuery.query('viewFichaDetalle #arbolcarpetas')[0].getStore().load();
而store的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派生的。 -
在你的 PHP 代码中,你想要实现什么?因为,我觉得 ExtJS 代码中没有问题,当您在树中展开一个节点时,商店 url 将被命中,并且该 php 代码将执行并返回相同的节点集。
-
您也可以发布您的回复数据吗?
-
我想创建只运行一次 php 的树,事实是当你展开一个节点时,它会再次执行 php,并将节点属性发送到该 php。所以我正在创建树像这样,在扩展节点时接收节点并添加其叶子
标签: javascript php extjs extjs4.2