日期:2014-05-16  浏览次数:20403 次

JsonStore中取数据和idProperty属性重复

最近使用Ext.data.JsonStore从后台取数据时,返回的数据多条数据,但是在现实时一直是一条数据,经过排除发现是因为返回数据中有个数据对象里面有个对象的名称也为id和JsonReader的idProperty默认的id属性重复。

js代码如下:

var pieStore = new Ext.data.Store({
			url : jspath+'Chaart/pie2/getGropGhgByOrgId.do' ,
			baseParams :{year_a:2011,month_a:4,orgid:"40288da02edcc901012edcd1f0da0008"},
			autoLoad: true ,
			reader :new Ext.data.JsonReader({
		    root: "test",idProperty: 'idabc'},[
			    {name: 'season',mapping:"id.gapType"},        
			    {name: 'total', mapping: 'total'}  
			])
	});

其中name的mapping对应的是id.gapType,{name: 'season',mapping:"id.gapType"},

返回的数据为:

{
	"month_a":4,
	"orgid":"40288da02edcc901012edcd1f0da0008",
	"test":[
		{
			"id":{"gapType":"CH4","month":2},
			"season":"CH4",
			"total":"31080.00000"
		},{
			"id":{"gapType":"CO2","month":3},
			"season":"CO2",
			"total":"2081.20000"
		},{
			"id":{"gapType":"HFCs","month":4},
			"season":"HFCs",
			"total":"10335780.00000"
		}
	],
	"year_a":2011
}	

?