-
19 Dec 2011 3:47 PM #1
sort an object based on field value
sort an object based on field value
Hi guys ,
I have a store which has a list of objects.
Model:
Store:Code:Ext.regModel("PF", { fields: [ { name: 'ParkingFacilities', type: 'auto' }, { name: 'ParkingZones', type: 'auto' }, { name: 'Facilities', type: 'auto' }, { name: 'ParkingSortFacilityID', type: 'auto' } ] });
If you see the image below, I am trying to sort all the object in the facility model by the field distance. But the item does not seem to be sorted.Code:App.stores.ParkingFacility = new Ext.data.Store({ model: 'PF', autoLoad: true, listeners: { dataChanged: function (store) { console.log('dataChanged'); } } });
JSON Returned:
JSON1.jpg
Can some one show me a sample on how to sort the data. I am really stuck at this.
Any help would be greatly appreciated.
Thanks ,
Pawan
-
20 Dec 2011 4:15 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
What is the type you have on the field Distance? You have it as a sting but it should be a float.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Dec 2011 10:14 AM #3
I created another variable called DistanceForSort with a type Decimal. It Does not seems to work. Do i need to do any kind of a refresh of the dataStore once the change has been made.
When i ran it for the first time through the chrome console it worked but after then I have tried so many time i does not seem to work
Any suggestion.
-Pawan.
-
20 Dec 2011 11:05 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
There is no type 'decimal'... it's float.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Dec 2011 11:21 AM #5
From my backed (C#) it is returned as a decimal value through json. after that i am trying to sort it.
If i my json element has a values returned as 0.16 is it considered as float by sencha or any other type ? Please look at the image attached . It has a green box at the bottom marked with comment.
Snap 2011-12-20 at 11.32.19.jpg
Regards,
Pawan Venugopal


Reply With Quote