PDA

View Full Version : GRID Sort on rendered column Help



dusoo
22 Jun 2010, 11:18 PM
Hi folks,
is it possible to sort a column which is created by using renderer ?
It does not sort for me, so i guess i'm missing something

second column (MaxOf %) - renderer:renderCol

Thanks a lot.
D.



function renderCol(value, metaData, record, rowIndex, colIndex, store) {
if(record.get('util_in') > record.get('util_out')){
return record.get('util_in');
}else {
return record.get('util_out');
}
}

var store = new Ext.data.Store({
url: 'report.php',
baseParams:{domain:'MBH', objThr: '', objDate: ''},
reader: new Ext.data.XmlReader({record: 'ROW'},
[
{name: "node", mapping:"NODE_NAME"},
{name: "util_in", type: 'float', mapping:"UTIL_IN"},
{name: "util_out", type: 'float', mapping:"UTIL_OUT"}
])
});

var grid = new Ext.grid.GridPanel({
store: store,
columns: [new Ext.grid.RowNumberer({width: 30}),
{header: "Node", width: 120, dataIndex: 'node', sortable: true},
{header: "MaxOf %", width: 100, renderer: renderCol, sortable: true},
{header: "MaxOf Util. in %", width: 100, dataIndex: 'util_in', sortable: true},
{header: "MaxOf Util. out %", width: 100, dataIndex: 'util_out', sortable: true}
],
width:800,
height:600
});

Condor
23 Jun 2010, 1:42 AM
There are several solutions:
1. Write a sortType function for the field (won't work in your case, because a sortType function doesn't have access to the whole record).
2. Use a calculated field (http://www.sencha.com/forum/showthread.php?28826-Calculated-fields).
3. Write a comparator function (http://www.sencha.com/forum/showthread.php?48334-Add-a-comparator-config-for-local-sort-on-Store).

dusoo
23 Jun 2010, 3:23 AM
Thanks