In the slickgrid I\'m able to set the sort column and it\'s sort direction using the grid.SetSortColumn(colName,true/false)
. This only sets the sorting glyph but do
I can't leave comments due to reputation, which is where this would be most appropriate, however, my answer is in regard to @Premshankar Tiwari and @Siddharth answers.
I preferred the dataView.fastSort
option in Siddharth's answer, which works for me in all browsers except IE7 and 8. I didn't test it in IE9 or above. Unfortunately, most on my network run IE7 or 8 due to compatibility issues for legacy applications. BUT, Premshankar's answer works in IE7 and 8.
So, I ended up doing something like this:
if (msie > 0) {
$(".slick-header-columns").children().eq(5).trigger("click");
$(".slick-header-columns").children().eq(4).trigger("click");
} else {
dataView.fastSort('process','unit');
}
where column index (5) = 'unit' and column index (4) = 'process'. Notice that is the reverse order in dataView.fastSort
method. I am also using a function that detects IE browser version and assigns it to msie
.
My only complaint about utilizing the .trigger
method is that if you set up your grid to dynamically hide/show columns, the indexed feature would potentially sort on unintended columns unless you are only calling it on initialization when hide/show capabilities are present.