PDA

View Full Version : Using . (dot) in model fields



sidoron
16 May 2012, 4:39 AM
Hi,

I a model that i am defining dynamically, in the store configuration i have useSimpleAccessors to avoid it reading name.name1.name3 as a tree element in the json

But when i am defining a model with fields like that i don't have this kind of property. i tries sefining a proxy for that model using the same settings as the store that are going to use it but than the chart does not load

can you help?

börn
16 May 2012, 5:03 AM
useSimpleAccessors is a config for the json reader - so you have to configure the reader of your model with this config and everything is fine again... seems to me that the store's config element is passed to it's reader, if you had really configured this at your store and it works ;)

sidoron
16 May 2012, 8:55 AM
I pin point the problem, when i am doing this:


var categories = ['name', ' data1. dd '];

Ext.define('Points', {
extend : 'Ext.data.Model',
fields : categories
});


there is no problem

but when i add another space afterwards like this:

var categories = ['name', ' data1. d d '];

Ext.define('Points', {
extend : 'Ext.data.Model',
fields : categories
});


it gives an error, i can't understand what's the difference because as i see it the model should not do anything related to getting the data, when i add this model to the store i can use useSimepleAccessors but here i have no option.

I am doing this because i am building my fields dynamically from a json, and this is a name of data that the clients enters, do i really have to parse it only to use it as a field, that's seems like a bug to me

15 Dec 2012, 12:18 PM
@börn: Thanks, just what i was looking for. Your answer is correct.

@sidoron: useSimepleAccessors is not a config option for the store, you should use it for the jsonreader configured in the proxy for the store.