-
7 Mar 2013 1:54 AM #1
Answered: Ext.data.reader.Json totalProperty with dot "."
Answered: Ext.data.reader.Json totalProperty with dot "."
Hi
I have an usual JSON comming back from server that looks like this:
where "data.length" is my totalProperty (number of total records in the dataset, for paging). The problem is when I put "data.length" into my totalProperty, it's trying to be clever and look for a "data" object with a "length" property. Is there any way of telling it not to be clever and just take the name as I've passed it?Code:{ "values": [...], "data.length": 100 }
Thanks.
Stevo
-
Best Answer Posted by skirtle
See:
http://docs.sencha.com/ext-js/4-1/so...createAccessor
You've got a wealth of options available, such as:
or:Code:totalProperty: '["data.length"]'
or useSimpleAccessors:Code:totalProperty: function(obj) { return obj['data.length']; }
http://docs.sencha.com/ext-js/4-1/#!...impleAccessors
-
7 Mar 2013 2:27 AM #2Ext JS Premium Member
- Join Date
- Nov 2007
- Location
- Sunny South Africa
- Posts
- 507
- Vote Rating
- 0
- Answers
- 1
javascript uses "." (dot) notation internally, so it's not advisable to use it in strings that could get confusing in a similar way to your json being misinterpreted. You wouldn't create an object with a key of "Object", would you?
{
"Object" : {}
}
Any chance you can change the dot to a different character?
-
7 Mar 2013 2:49 AM #3
-
7 Mar 2013 4:31 AM #4
See:
http://docs.sencha.com/ext-js/4-1/so...createAccessor
You've got a wealth of options available, such as:
or:Code:totalProperty: '["data.length"]'
or useSimpleAccessors:Code:totalProperty: function(obj) { return obj['data.length']; }
http://docs.sencha.com/ext-js/4-1/#!...impleAccessors


Reply With Quote