Sorting Grid API results is easy, powerful, and optional.
To specify a sort order in your request, include thet sortBy
property, like this:
Example sort order request
{
... // other fields omitted for brevity
"sortBy": [
{
"columnId": "COLUMN_ID",
"direction": "asc" // or "desc" for descending
}
]
}
If your primary sort column has many rows with the same value, you can specify more sort columns to break ties:
Example request to sort by multiple columns
{
... // other fields omitted for brevity
"sortBy": [
{
"columnId": "COLUMN_ID_1",
"direction": "asc"
},
{
"columnId": "COLUMN_ID_2",
"direction": "asc"
}
]
}