我在一个tabpanel中有一个treepanel:
TREE PANEL
var storeTreePanel= Ext.create('App.store.strTreePanel');
var tabpanelsecundario4_1 = new Ext.tab.Panel({
itemId : 'tabpanelsecundario4_1',
region : 'center',
layout : 'fit',
width : "100%",
height : "100%",
border : false,
activeTab: 1,
items:[
{
itemId : 'tabDatosEconomicos',
title : '<span style="color:#C85E00;font-weight:bold;">Datos Economicos</span>',
layout:'fit',
items:[
{
xtype : 'treepanel',
itemId : 'gridCriteriosLostes',
autoScroll : true,
store : storeTreePanel,
rootVisible : false,
columns : [
{header:'<span style="color:#C85E00;">Column1</span>', dataIndex:'text', itemId:'', flex:3.5},
{header:'<span style="color:#C85E00;">Column2</span>', dataIndex:'referencia', itemId:'', flex:1},
{header:'<span style="color:#C85E00;">Column3</span>', dataIndex:'producto', itemId:'', flex:2},
{header:'<span style="color:#C85E00;">Column4</span>', dataIndex:'unidades', itemId:'', flex:1},
{header:'<span style="color:#C85E00;">Column5</span>', dataIndex:'ofertado', itemId:'', flex:1, align:'center'},
{header:'<span style="color:#C85E00;">Column6</span>', dataIndex:'importe', itemId:'', flex:1, align:'right'},
{header:'<span style="color:#C85E00;">Column7</span>', dataIndex:'baja', itemId:'', flex:0.5, align:'right'},
{header:'<span style="color:#C85E00;">Column8</span>', dataIndex:'adj', itemId:'', flex:0.5, align:'center'},
{header:'<span style="color:#C85E00;">Column9</span>', dataIndex:'motivos', itemId:'', flex:2.5}
]
}
]
}
]
});
TREEPANEL STORE
Ext.define('App.store.strTreePanel', {
extend: 'Ext.data.TreeStore',
model: 'App.model.mdlTreePanel',
autoLoad: false,
folderSort: true,
proxy: {
type: 'ajax',
api: {read: './data/php/FillTreePanel.php'},
reader: {
type: 'json',
root: 'data',
totalProperty: 'total',
successProperty: 'success'
}
}
});
TREEPANEL模型
Ext.define('App.model.mdlTreePanel', {
extend: 'Ext.data.Model',
fields:[
{name:'id', type:'string', mapping:''},
{name:'text', type:'string', mapping:''},
{name:'referencia', type:'string', mapping:''},
{name:'producto', type:'string', mapping:''},
{name:'unidades', type:'integer', mapping:''},
{name:'ofertado', type:'boolean', mapping:''},
{name:'importe', type:'float', mapping:''},
{name:'baja', type:'float', mapping:''},
{name:'adj', type:'boolean', mapping:''},
{name:'motivos', type:'text', mapping:''},
{name:'leaf', type:'boolean', mapping:''}
]
});
PHP文件
<?php
mysqli_query($connection,"SET NAMES 'utf8'");
$sql="some select";
$result=mysqli_query($connection,$sql);
$data = array();
while($row = mysqli_fetch_array($result)){
array_push($data, array(
"id" => $row[data1],
"text" => $row[data2],
"referencia" => $row[data3],
"producto" => $row[data4],
"unidades" => $row[data5],
"ofertado" => $row[data6],
"importe" => $row[data7],
"baja" => $row[data8],
"adj" => $row[data9],
"motivos" => $row[data10]
));
$linea++;
}
echo json_encode(array(
'success'=>true,
'total'=>count($data),
'data'=> $data,
'sql'=> $sql
));
?>
当我返回数据时,我没有得到任何父文件夹,所有数据都显示为叶子。
我是否以错误的格式返回数据?
创建返回数据的php有什么问题吗?
在sencha(link)的文档中,它使用静态数据从javascript创建商店,但我的数据是dinamic并且我还没有找到关于如何从php文件创建数据的任何指南或信息并将其归还。
答案 0 :(得分:0)