Customizing sorting from multiple record fields with the web UI framework

You can customize the sorting of table columns that use data that combines multiple fields of a record (for example, by using a renderer). You can do this with both Ext JS 2.2.1 and Ext JS 3.0.2.

Perform this sort by using the sortType function in the class. Instead of one item being passed to sortType (value of a field), three items will be passed (value of a field, the record, and the field being sorted). This functionality is provided by overriding the sortData method in the class to pass the record and field in addition to the value of the field.

When users are not creating the store for a grid, they can pass sortType as a config option in the bindingData.sFieldConfig property in the columnModel or columns of a grid.

For example, a grid can have the following configuration:

columns: [{
  dataIndex: 'airlines',
  bindingData: {
    sFieldConfig : {
      mapping : "airlines",
      sortType: this.sortTypeFn

where this.sortTypeFn is defined in the screen JavaScript file as:

sortTypeFn: function(val, rec, fld){
              return val + rec.get('airlinenumber');    
              // computing the value based on value of field (airlines) and 
              // value of 'airlinenumber' field