I am creating a Ext.data.JsonStore for dispalying a chart. The data store it built in C# code behing and inserted into the page via:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Data", dataScript, true);
This is the resulting javascript code:
var store = Ext.create('Ext.data.JsonStore', {
fields: ["name", "ASAP", "Phase 2", "test", "Version 2.0 SR 1"],
data: [
{ "name": "ASAP", "ASAP": 30, "Phase 2": 10, "test": 5, "Version 2.0 SR 1": 10 } ,
{ "name": "Phase 2", "ASAP": 12, "Phase 2": 5, "test": 15, "Version 2.0 SR 1": 5 }
]
});
The problem is that in the field “Version 2.0 SR 1” there is a ‘.’ that is causing an a script error.
The error that it returns is:
SCRIPT1004: Expected ';'
ext-all.js, line 18 character 5081
I am assuming that I need to encode in some manner, but I have tried modifying the field to with no avail:
Version 2\\.0 SR 1
Version 2\.0 SR 1
Version 2\u002E0 SR 1
If I remove the ‘.’ or replace it with ‘_’ the code works.
The Ext.data.JsonStore class automatically configures itself with a proxy/reader configuration like this:
However, this isn’t sufficient for the case you’ve described, since you need to enable the useSimpleAccessors config on the JSON reader. The solution, then, is to use a regular Ext.data.Store instead, and specify the proxy and reader explicitly: