sort

sorts data items in a component

void sort(object rule,object config);

Parameters

ruleobjectan object with parameters for sorting
configobjectdefines the parameter of sorting

Example

grid.data.sort({
    by:"a",
    dir:"desc",
    as: function(item){
        return item.toUpperCase(); 
    }
});
 
// cancels applied sorting rules
grid.data.sort();

Related samples

Details

The rule object has the following attributes:

Calling the method without parameters will discard all applied sorting rules.

The config parameter may contain one property:

grid.data.sort({
    by:"a",
    dir:"desc",
    as: function(item){
        return item.toUpperCase(); 
    },
    {
        smartSorting: true     }
});

Custom sorting

To set a custom function for sorting you need to specify the rule attribute in a passed object. For example:

grid.data.sort({
    rule: (a, b) => a.id > b.id ? 1 : (a.id < b.id ? -1 : 0) 
});
Change log

The config parameter is added in v7.0.

Back to top