Results 1 to 7 of 7

Thread: Store - sorting not working reliably

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Answers
    4

    Default Store - sorting not working reliably

    [email protected],

    I am experiencing problems with sorters. I tried both defining sort directly in the store with a sorter and also to sort separately (I want to change sorting of store/list on the push of a button - which I have implemented already but it doesn't work reliable - sorts are messed up most of the time).

    The value I am trying to sort is of the type float... but somehow it just doesn't re-arrange the store correctly (talking about ~40-50items) that is linked to a list. My understanding is that when I re-arrange the store that the list is updated automatically since I can see the list change when I call e.g. store.sort('bla', 'DESC').

    As mentioned also defining a sorter directly on the store does not work correctly/reliably

    Code:
                sorters: [
                    {
                        sorterFn: function(record1, record2) {
                            return parseFloat(record1.get('distance')) > parseFloat(record2.get('distance')) ? 1 : (parseFloat(record1.get('distance')) === parseFloat(record2.get('distance')) ? 0 : -1);
                        },
                        direction: 'ASC'
                    }
                ],
    also

    Code:
    store.sort('distance', 'DESC')
    returns inconsistent sorting!

    Is there a proper way maybe to manually sort a store / re-arranging the items in the worst case with a loop?

    Help would be greatly appreciated.

    cheers,
    Alex

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    So you sort the store once and it works but if you sort it again it doesn't work?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Answers
    4

    Default

    No, also on the first sort it sorts the first ~20 elements correctly and then it is all mumbled. If I set the store to remote sort true and load it via the backend it is correct though.

    If I want to sort locally it doesn't matter if I define it directly in the store or afterwards with the .sort() method... it is not reliable and will return almost random results. I am using 2.0.0 at this time.. 2.1 exhibits the same problem - I temporarily upgraded to that version to test it as well.

    Any help on this is greatly appreciated.

    thanks,
    Alex

  4. #4
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Answers
    4

    Default

    Nobody an idea? What would be the most efficient way to manually sort the store?

    thanks,
    Alex

  5. #5
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64

    Default

    "distance" and "bla"
    why you sort different fields in one sorter?
    I write English by translator.

  6. #6
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Answers
    4

    Default

    Sorry thats my bad - it is actually only one field per sort (corrected the sample)

    So I would like to sort by distance DESC; the store type is defined as float... but it is not correctly sorted. Also if I remove the sorter and do it manually via store.sort('distance', 'DESC') it does not sort correctly.

    At the end I want to sort between two different values via the .sort method but it seems that the sorter just sorts it randomly even though I pass the values correctly (either directly at the store or via the .sort method).

    cheers,
    alex

  7. #7
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    209
    Answers
    4

    Default

    I saw that the store has a method _autoSort: true and I suspect this is the problem. Is there a possiblity to disable any kind of auto behaviour to avoid issues like this?

    thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •