1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Vote Rating
    1
    Answers
    1
    JoostvanGaalen is on a distinguished road

      0  

    Default Answered: Query out of XML

    Answered: Query out of XML


    Hello,


    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,

  2. 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.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,546
    Vote Rating
    873
    Answers
    3566
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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 Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Vote Rating
    1
    Answers
    1
    JoostvanGaalen is on a distinguished road

      0  

    Default


    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

Thread Participants: 1

Tags for this Thread