PDA

View Full Version : About JsonStore, how it get data from JSon data, the data with Composite primary key



davidzheng
15 Jan 2015, 2:20 PM
Hi There,

My code and sample data below:
My JSonStore can't get data from Java.
Composite primary key is PO and STYLE_NO
-----------------------------------------
var store = new Ext.data.JsonStore({

var PaymentObj = [
{ name:'id', type:'string'},
{ name:'id.po', type:'string'},
{ name:'id.style_no', type:'string'},
{ name:'totalfee', type:'string'},
{ name:'paidfee', type:'string'},
{ name:'paydate', type:'string'}
];

//Data
var store = new Ext.data.JsonStore({
url: 'payment_findPagePayment.do',
root: 'root',
totalProperty: 'total',
autoLoad: {params:{start:0, limit:15}},
fields: PaymentObj
});

//List
var grid = new Ext.grid.GridPanel({
store: store,
cm: new Ext.grid.ColumnModel({
defaults: { menuDisabled : true},
columns:[new Ext.grid.RowNumberer(),
{header: 'Client PO', width: 150,align:'center', dataIndex: 'id.po'},
{header: 'Style No', width: 150,align:'center', dataIndex: 'id.style_no'},
{header: 'Total', width: 150, align:'center',dataIndex: 'totalFee'},
{header: 'Paid', width: 150, align:'center',dataIndex: 'paidFee'},
{header: 'Date', align:'center',dataIndex: 'payDate'}]
}),.......
----------------------------------------------
//Sample JSon data from java action
{total:2,
root:[{"id":{"po":"56777","styleNo":"AAA1310"},
"paidFee":500,
"payDate":{"date":5,"day":1,"hours":0,"minutes":0,"month":0,"nanos":0,"seconds":0,"time":1420387200000,"timezoneOffset":-480,"year":115},
"styleNo":"AAA1310","totalFee":1000},
{"id":{"po":"56778","styleNo":"AAA0024"},"paidFee":600,
"payDate":{"date":6,"day":2,"hours":0,"minutes":0,"month":0,"nanos":0,"seconds":0,"time":1420473600000,"timezoneOffset":-480,"year":115},
"styleNo":"AAA0024","totalFee":2000}]}
------------------------------------------
Thanks a lot

lumberjack
19 Jan 2015, 11:17 AM
You'll need to use a convert function to concatenate two other mapped fields.

Regards,
Brian

gmq

davidzheng
19 Jan 2015, 5:38 PM
Thanks a lot,,

davidzheng
19 Jan 2015, 10:23 PM
my Extjs version is 3.3.0, there are no Ext.data.Model. So How can I handle Composite primary key? And could you give sample code that how load into the Ext.data.JsonStore? Thanks a lot