[DT 1.9.4] How to implement own sorting mechanism?
[DT 1.9.4] How to implement own sorting mechanism?
Hi, I am trying to detect the click on header for sorting on datatable, so that I can call my own sorting functions. I can detect the click using dataTable.on('click', 'thead tr>th:nth-child(1))
and bSort:false
but I don't get the nice UI features that datatable provides when sorting is enabled (Bold header, with sorting direction).
So my question is, is there any way to get the UI features, while not calling the built-in sorting function fnSort()
(overriding the function)?
Thanks a lot for all your help.
Answers
I was able to get what I needed. I disabled sorting using datatables. Added "sorting_asc/sorting_desc" to my column header, along with the placeholder for the icon. Removed class "sorting_disabled" using js from the header. Then implemented the click event on the header using this:
this.$tableEl.on('click', 'thead tr>th:nth-child(1)', function(){
//implement sort
});
Thanks a lot for the nice table.