Results 1 to 6 of 6

Thread: PagingMemoryProxy sorting problem

  1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    21

    Default PagingMemoryProxy sorting problem

    I'm using PagingMemoryProxy to display a grid. The store is configured with the 'remoteSort:true'. So the sorting is supposed to be handled by the proxy which takes the server place and should provide both pagination and sorting. It looks like in 3.0 version the sorting is broken. On a closer look there is a code change from 3.0 version of the PagingMemoryProxy and the 2.x one.

    3.0
    Code:
                var dir = String(params.dir).toUpperCase() == 'DESC' ? -1 : 1;
                var fn = function(r1, r2){
                    return r1 < r2;
                };
                result.records.sort(function(a, b){
                    var v = 0;
                    if (typeof(a) == 'object') {
                        v = fn(a.data[params.sort], b.data[params.sort]) * dir;
                    }
                    else {
                        v = fn(a, b) * dir;
                    }
                    if (v == 0) {
                        v = (a.index < b.index ? -1 : 1);
                    }
                    return v;
                });
    2.x code:
    Code:
                var dir = String(params.dir).toUpperCase() == "DESC" ? -1 : 1;
                var fn = function(v1, v2){
                    return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
                };
                result.records.sort(function(a, b) {
                    var v = 0;
                    if (typeof(a)=="object"){
                        v = fn(a.data[params.sort], b.data[params.sort]) * dir;
                    } else {
                        v = fn(a, b) * dir;
                    }
                    if (v==0) {
                        v = (a.index < b.index ? -1 : 1);
                    }
                    return v;
                });
    Looks like the "fn" function in the 3.0 now returns a boolean where it should return a integer like the 2.0 one, which causes the sort algorithm to fail. Is this supposed to be like this, or it is a bug?

  2. #2
    Sencha User
    Join Date
    Sep 2008
    Posts
    21

    Default Is this a bug in 3.0?

    Can somebody check if this is a bug or not?
    Thanks!

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Looks like a bug. When you change the code back your sorts all work OK?

  4. #4
    Sencha User
    Join Date
    Sep 2008
    Posts
    21

    Default

    Yes, it works fine.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Report it in the bugs forum. Looks like a simple fix.

  6. #6
    Sencha User
    Join Date
    Sep 2008
    Posts
    21

    Default

    ok, will do, 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
  •