| sidebar_label | sortCells() |
|---|---|
| title | sortCells method |
| description | You can learn about the sortCells method in the documentation of the DHTMLX JavaScript Spreadsheet library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Spreadsheet. |
@short: Sorts data in the spreadsheet
sortCells(cell: string, dir: number): void;cell- (required) the id(s) of a cell(s) or a range of cells by which you want the data in the spreadsheet to be sorteddir- (required) the direction of sorting:- 1 - ascending order
- -1 - descending order
const spreadsheet = new dhx.Spreadsheet("spreadsheet", {
// configuration parameters
});
spreadsheet.parse(data);
// sorts data on the first sheet
spreadsheet.sortCells("B2:B11", -1);
// sorts data on several sheets
spreadsheet.sortCells("Income!B2:B11, Report!B2:B11, Expenses!C2:C11", 1);Related sample: Spreadsheet. Initialization with multiple sheets
Related articles: Sorting data