I cannot leave comments because of the reputation, and this would be most appropriate, however my answer concerns the answers of @Premshankar Tiwari and @Siddharth.
I preferred the dataView.fastSort
option in Siddhart's answer, which works for me in all browsers except IE7 and 8. I have not tested it in IE9 or higher. Unfortunately, most of my network runs IE7 or 8 due to compatibility issues for legacy applications. BUT, Premshankar 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". Note that this is the reverse order in the dataView.fastSort
method. I also use a function that detects the IE browser version and assigns it to msie
.
My only complaint about using the .trigger
method is that if you set your grid to dynamically hide / show columns, the indexed function will potentially sort by unexpected columns, unless you only call it during initialization, when the hidden / displayed capabilities are present .
source share