A grid control column is ordering based on name
which is a combined field of first + ' ' + last
. The client wants to order by last + ', ' + first
. I am not permitted to change the existing code, can only use overrides.
Based on the results of web searching, I think using sortType
to transform the input value is the least intrusive approach. But I'm not sure how to plug it in.
I think sortType
works on data fields, so in an initComponent
overload can I get access to what I need? For example, this is how I override in the view to change the rendering:
initComponent: function() {
this.callParent([]);
this.columns[0].renderer =
function(value, metaData, record, rowIdx, colIdx, store, view) {
var result = '';
if (!Ext.isEmpty(record.data) && !Ext.isEmpty(record.data.details)) {
var details = record.data.details;
// value == details.name is 'first last', won't be using that
result = details.last + ', ' + details.first;
}
return result;
};
}
Can I get access to the details.name
definition from here to override sortType
? Will agree that this isn't the best approach, because I'll have to do some parsing of name
to split it and then stick it back together. And that's going to have issues for those with multiple first and/or last names.
An alternate approach is to overload doSort
but if I don't have access to details.first
and details.last
, it won't be any better than sortType
. I saw one example of implementing doSort
and it looks very complicated. Does anyone know of some detailed documentation for doSort
?