Search code examples
sortingextjscolumnsortingcolumnheader

How to local sorting when click datagrid column header as ASC and DESC in Ext Js


Im working in Ext Js.When i click column header for sorting alphabetically.some local character doesnt working properly.

ForExample :

Emma-Sarah-Tom-Şehmus

'Ş' is local charecter.

And i try to trigger 'headerclick' event as below

 listeners: {
            headerclick : function(grid,col,e){
                this.store.setSorterFn(function (record1, record2) {
                    var productLine1 = record1.get(col.formName),
                        productLine2 = record2.get(col.formName);
                    return productLine1.localeCompare(productLine2);
                });
            }

but i cant manage sorting when i click header of column


Solution

  • You need not handle the headerclick you can handle the custom sorting using the sorter config of the column .

    Reference :- https://docs.sencha.com/extjs/6.7.0/classic/Ext.grid.column.Column.html#cfg-sorter

    Hope this would help You