1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default 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:

    Code:
    Ext.regModel("PF", {
        fields:
            [
                { name: 'ParkingFacilities', type: 'auto' },
    
                { name: 'ParkingZones', type: 'auto' },
    
                { name: 'Facilities', type: 'auto' },
    
               { name: 'ParkingSortFacilityID', type: 'auto' }
    
           ]
    
    });
    Store:

    Code:
    App.stores.ParkingFacility = new Ext.data.Store({
        model: 'PF',
        autoLoad: true,
        listeners: {
            dataChanged: function (store) {
                console.log('dataChanged');
            }
        } 
    });
    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.

    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    854
    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


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

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    854
    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


    There is no type 'decimal'... it's float.
    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.

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default


    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

Thread Participants: 1

Tags for this Thread