PDA

View Full Version : How can I sort a templatecolumn in a grid?



rabelanger
26 Apr 2012, 2:07 PM
Hi,

I have a standard Ext.grid.Panel with 5 columns, where 2 of them are templatecolumn. My model used in the store of the grid has 2 relation 'belongsTo' which are are loaded when the grid's store is loaded, using the associationKey. Such as:



associations: [{
type: 'belongsTo',
model: 'Dash.model.production.civmil.Priority',
name: 'Priority',
associationKey: 'Priority',
getterName: 'getPriority',
setterName:'setPriority'
},
{
type: 'belongsTo',
model: 'Dash.model.air.AirportProduct',
name: 'AirportProduct',
associationKey: 'AirportProduct',
getterName: 'getAirportProduct',
setterName: 'setAirportProduct'
}


I use the template column to render my model's relation value into the grid like this



{
id: 'AirportName',
text: 'ICAO',
flex:1,
xtype: 'templatecolumn',
tpl: '{AirportProduct.Airport.AirportICAO}'
}


I pretty sure it ain't sorting because I dont have a dataIndex binded to my column, but I don't really have one since I just want to display the value of my association.

How can I sort my data of the templatecolumn?

skirtle
26 Apr 2012, 8:06 PM
I needed to do a similar thing. Extend templatecolumn and override doSort (see the source for a normal column for the default implementation). Then you can implement whatever sort you like on that column.