A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.dhtmlx.com/suite/data_collection/api/datacollection_sort_method/ below:

Website Navigation


JavaScript DataCollection - sort Method

sort()

sorts data items in a component

sort(rule?: object, config?: object): void;

Parameters:

Example

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

// cancels the applied sorting rules
grid.data.sort();

Related sample: Data. Sorting

note

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

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4