27 Aug 2012 2:35 AM #1
Answered: Query out of XML
Hello, i am a beginner with this program (and kind of with the method MVC) and I encountered a problem.
I am loading in an XML into a list, which all works fine. However, i want the list to be sorted by closest location. The XML sheet has a lat and a long field. I want those values to be compared to the current location I am at and then sort out of the list.
How am i doing this? Cause I have no clue how to adres a query in here.
Thank you very much for your effort already,
You can use store.sort and pass in an Ext.util.Sorter with a custom sortFn that compares the distances unless you return the distance in your data.
29 Aug 2012 4:33 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
You can use store.sort and pass in an Ext.util.Sorter with a custom sortFn that compares the distances unless you return the distance in your data.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
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 firstname.lastname@example.org
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
4 Sep 2012 12:09 AM #3
Thanks, sorted it out. I applied an onstoreload function. I applied an extra field in my xml called distance, and on the onstore load, i let the data run through a loop. This loop determines the distance between the 2 points and converts that into kilometers. Then it stores the data distance in the xml file, and after its done its run, it sorts it by distance. Took a bit to figure it out, but happy it worked out.
The sad part is that I had to do it the old way, and cant use the distanceFrom function anymore that was used in the old google maps api 2.0 ... in 3.0 it doesnt seem to excist anymore. Glad i found a way arround it though.
Thanks for the hint, Mitchell