Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.84 KB

File metadata and controls

61 lines (51 loc) · 1.84 KB
sidebar_label getSortingStates()
title JavaScript DataCollection - getSortingStates Method
description You can explore the getSortingStates method of DataCollection in the documentation of the DHTMLX JavaScript UI library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Suite.

getSortingStates()

@short: returns an array of objects with the current parameters of sorting applied to the data

Usage

interface ISortingState {
    by: string | number, 
    dir: "asc" | "desc", 
    as?: (a) => any,
    rule?: (a, b) => number, 
    smartSorting?: boolean 
}

getSortingStates(): ISortingState[];

@returns: An array of objects with the current parameters of sorting applied to the data.

@example: const state = grid.data.getSortingStates(); // -> [{ by: "country", dir: "desc" }, { by: "population", dir: "desc" }]

@descr: The array returned by the method contains objects with the following properties:

by (string | number) the id of a data field to sort by
dir (string) the direction of sorting: "asc" or "desc"
as (function) optional, a custom function of converting values before comparing
rule (function) optional, a custom sorting function
smartSorting (boolean) optional, (if applied) specifies whether a sorting rule should be applied each time after changing the data set

@changelog: added in v9.1