Siddharth
Siddharth

Reputation: 177

Getting sort details in SlickGrid

How to get the name/id of the sort column and the sort-order of the column in slickgrid?
I'm able to set the sort column using grid.setSortColumn("column"), and would like to get the sort column and it's sort order.

Upvotes: 0

Views: 2467

Answers (2)

Magdalena Kalcheva
Magdalena Kalcheva

Reputation: 31

 grid.getSortColumns()

will give you array of objects like this :

[Object { columnId= "ProjectProgram",  sortAsc=false}]

Upvotes: 3

dexter
dexter

Reputation: 13593

You can access it in the callback function to onSort:

var grid = new Slick.Grid("#sf_grid", dataView, columns, options);

grid.onSort.subscribe(function(e, args) {
    var sortdir = args.sortAsc ? 1 : -1; //get the sort order
    var sortcol = args.sortCol.field;    //get the sort column
});

Upvotes: 0

Related Questions