php:
while($row = mysql_fetch_array($result))
{
$res[$i]['oid']=$row['oid'];
$res[$i]['uname']=$row['uname'];
$res[$i]['odate']=$row['odate'];
$res[$i]['oispro']=$row['oispro'];
$res[$i]['gid']=$row['gid'];
$i++;
}
echo json_encode($res);
js:
$.post(
'../php/loadOrderData.php',
{},
function(res) {
$("#circular-loading").addClass('hidden');
drawTable1(res);
}
);
function drawTable(res){
var store = new Ext.data.JsonStore({fields:[ 'oid', 'uname', 'odate' ],
data:$.parseJSON(res)
});
console.log('res',res);
console.log('res1',$.parseJSON(res));
var columns = new Ext.grid.ColumnModel({
columns:[
{ header:'订单编号', dataIndex:'oid', width:100,sortable:true},
{ header:'商品名称', dataIndex:'uname', width:100,sortable:true },
{ header:'购买时间', dataIndex:'odate', width:100,sortable:true}
]
});
var grid = new Ext.grid.GridPanel({
title:'GridPanel',
width:680,
height:200,
store:store,
viewConfig:{
forceFit:true
},
colModel:columns,
tools:[
{id:'close',qtip:'关闭'},
{id:'refresh',qtip:'刷新'},
]
});
grid.render('columns');
}
采用直接方式
var store = new Ext.data.JsonStore({
fields:[ 'oid', 'uname', 'odate' ],
url:'../php/loadOrderData.php',
remoteSort:true
});不行