PDA

View Full Version : Grid sort with conditions



paubach
19 Jun 2009, 7:56 AM
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 "-".



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

paubach
22 Jun 2009, 12:27 AM
Any help on this?

mm_202
30 Jun 2009, 12:05 PM
Im trying to override the default sort function since I have a custom column renderer and it messes up my sort. Any ideas?