Sorting
This section covers the methods to handle the table sorting
Documentation
orderBy
Sorts the rows of a worksheet based on the values in a column, or in several columns with levels.
| Parameter | Description |
|---|---|
columnNumber |
Column that will decide the new order. |
direction |
The direction of ordination. false is equivalent to ascending sorting and true is equivalent to descending sorting. |
levels |
Version 13. JSON array of sorting levels [{ column, direction }, ...], applied in order: ties on one level resolve on the next. When present, columnNumber and direction are ignored. |
POST /api/:guid/:worksheetIndex/order
Examples
Sorting the data in a column
const baseUrl = 'http://localhost:8009/api';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };
// Sort the third column in ascending order
await fetch(`${baseUrl}/${guid}/0/order`, {
method: 'POST',
headers,
body: new URLSearchParams({
'columnNumber': '2',
'direction': 'false',
}),
});
Sorting by several columns
Sort by the third column ascending, then by the first column descending for the rows that tie.
await fetch(`${baseUrl}/${guid}/0/order`, {
method: 'POST',
headers,
body: new URLSearchParams({
'levels': JSON.stringify([
{ column: 2, direction: 0 },
{ column: 0, direction: 1 },
]),
}),
});