Reputation: 105
I want to sort multiple columns at a time programatically. I am NOT using the default sorting method which is to click on header name to sort and ctrl/shift key + header name to sort multiple columns. I have a different option in the column options menu which is used to sort that specific column. For single column sort, I am using the following api.
params.api.setSortModel([
{
colId: params.column.colId,
sort: "asc",
}
Is there any api or anyway to sort multiple columns?
Upvotes: 1
Views: 6946
Reputation: 7614
You need to construct a sortModel object which looks like this -
var sortModel = [
{
"colId": "athlete",
"sort": "desc"
},
{
"colId": "country",
"sort": "asc"
}
]
Then you can use the sorting api, the way you have used it and pass this model which is just an array containing more than one column instead of single column the way you have it in question
params.api.setSortModel(sortModel);
Example on sorting api.
Upvotes: 4