Results 1 to 3 of 3

Thread: Grid sort with conditions

  1. #1
    Ext JS Premium Member paubach's Avatar
    Join Date
    Jan 2008
    Location
    Plasencia, Spain
    Posts
    346

    Default Grid sort with conditions

    Hi,
    I have a grid with incidents, and I'm trying to do a special sort for a column with numbers (type:int) but there are some values that aren't numeric ("-" when no applies).

    To sort this I'd like to have first numeric values in asc or desc order depending of what is chosen and then all the other incidents with this value equals to "-".

    Code:
    FUNC TO SORT BY:
        var sortByIdle = (function(){
            return function(r){
                if(isNaN(r))
                    if(grid.sortInfo.direction="DESC") return -99999999;
                    else return 999999999;
                return r;
            }
        })();
    
    
    
    STORE
    ...
    {name: 'idl', mapping:'idl', type: 'int'},
    ...
    
    
    COLUMN MODEL
    ...
    {header: 'Idle', width: layOpts.idlSz.valueOf(), hidden: !layOpts.idlOn, sortable: true, dataIndex: 'idl', align: 'right', sortType: sortByIdle,
            renderer: function(v,record,colIndex) {
                if (isNaN(v))
                    return "-";
                if(v<2000000) return v;
                else 
                {
                    var d= new Date();
                    var numVal=(v-2440589)*86400000;
                    d.setTime(numVal);
                    return Ext.util.Format.date((d.getUTCMonth()+1)+'/'+d.getUTCDate()+'/'+d.getUTCFullYear(),'m/d/y');
                }
              }};
    ...
    It's not working (other way I wouldn't post here :P).
    Any help on this?

    Thanks,
    Pau

  2. #2
    Ext JS Premium Member paubach's Avatar
    Join Date
    Jan 2008
    Location
    Plasencia, Spain
    Posts
    346

    Default

    Any help on this?

  3. #3
    Ext JS Premium Member mm_202's Avatar
    Join Date
    Dec 2007
    Location
    USA
    Posts
    59

    Question Same Issue..

    Im trying to override the default sort function since I have a custom column renderer and it messes up my sort. Any ideas?

Posting Permissions

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