View Full Version : How to create custom sort label text in Ext.grid.column.Column header

27 Apr 2016, 7:11 AM
I need to create a custom sort label/text for a column header for Sort Ascending and Descending order functionality.
I am using Ext JS version 4.1.1.
Again, I need to change the sort label of column header in Ext.grid.column.Column.
a)From 'Sort Ascending' to 'Sort by Oldest'
b)From 'Sort Descending' to 'Sort by Newest'
I created a sort function:-
var createSortFunctionExtJs = Ext.data.Store.prototype.createSortFunction;
Ext.override(Ext.data.Store, {
createSortFunction: function(fieldName) {
var fields = this.fields.get(fieldName);
if (!fields || !fields.sortFunction) {
return createSortFunctionExtJs.call(this, fieldName);
var f = fields.sortFunction;
return function (r1) {
return f(r1);
And called it in Ext JS file:-
var fields = {
dataIndex: "effectiveDate",
sortFunction: function(r1) {
r1.sortable(true).getSortParam('ASC').setFieldLabel('Sort by Oldest');
It is not creating the custom sort label as required.
Thanks in advance,

Gary Schlosberg
28 Apr 2016, 2:51 PM
You can do something similar to the locale files:

Ext.define("Ext.locale.en.grid.header.Container", {
override: "Ext.grid.header.Container",

sortAscText: "Sort by Oldest",
sortDescText: "Sort by Newest"