PDA

View Full Version : [CLOSED][3.1.1] ArrayStore fields problem.



jeroenooms
15 Mar 2010, 4:03 PM
The initiation of an ArrayStore fails when one of the fields contains a dot followed by a number. For example, newStore1 works, but newStore2 fails in this example:


var myData = [["john",110],["alice",95],["bob",105]]

var newStore1 = new Ext.data.ArrayStore({
fields: ["name","result.blaa"], // THIS WILL DO OK
data: myData
});

var newStore2 = new Ext.data.ArrayStore({
fields: ["name","result.2009"], // THIS WILL CREATE PROBLEMS
data: myData
});
will cause the error:

missing ; before statement
return obj.result.2009 ext-all-debug.js (line 36306)

evant
15 Mar 2010, 4:25 PM
Because JS property names can't start with a number, you need to prefix it with an alpha character or an underscore.

jeroenooms
15 Mar 2010, 4:29 PM
It's not a property, it's just a name that happens to contain a dot. The problem is exactly that Ext treats it as a property.

I am not trying to create a property called '2009' in the example. The user just happened to have a dataset, in which one of the variables is called 'result.2009' (i.e. one big string).

evant
15 Mar 2010, 4:33 PM
Alternatively, you can pass in a mapping to extract the value.