PDA

View Full Version : about JsonStore fields config : contain decimal point



szxiaoyin
19 Jul 2010, 8:47 PM
my fields is dynamic , the json data contain decimal point ,the take a error

like this:

var fieldAccount =
[
{ name:"KeyId"},
{ name:"Remark"},
{ name:"StartDate"},
{ name:"EndDate"},
{ name:"QuoteType"},
{ name:"1.5"},
{ name:"1.8"}
];

thks!!!!

Animal
19 Jul 2010, 9:36 PM
That's not JSON data.

That's a record definition.

In which you have a field name of "1.5"?

szxiaoyin
19 Jul 2010, 10:40 PM
yes ,a field name of "1.5"

because i want show a grid with fuel consumption like this :



Start | End |1.5 tons | 3 tons | 5 tons
-----------------------------------------------
add1 add2 10 15 20

Animal
20 Jul 2010, 12:20 AM
OK, then what's your question?

Condor
20 Jul 2010, 1:12 AM
Don't use '.' in field names. Why not name your field '1_5' (you can still use '1.5 tons' as the column header).

If you can't change your server to avoid '.' then you could use:

{name: '1_5', mapping: function(n){return n['1.5'];}},

Animal
20 Jul 2010, 1:24 AM
Of course you'd have to send standards-compliant JSON to feed that Reader:



{ "1.5": 15, "1.8": 20}


as opposed to



{ 1.5: 15, 1.8: 20}


Which would thrown an error.

szxiaoyin
20 Jul 2010, 2:00 AM
thanks ,

the error is "miss ; "