Javascript Method Custom Sort
Javascript Method Custom Sort
Hi Alan,
I have been trying to disable standard sorting on the datatable using :
$('#example th').unbind('click.sorting'); OR $('#example thead').unbind('click.sorting');
The sort does not get disabled. The following is my initialisation code
$('#example').dataTable({
"processing":true,
"scrollX": true,
"scrollY": "300px",
"scrollCollapse": true,
"paginate": false,
"dom": "C<'clear'>lrtip",
"colVis": {
"exclude": [0,1],
"showAll": "Show all",
"align":"left"
},
"columns":
[
{ "title": "Row ID", "visible" : false },
{ "title": "<button onclick = 'DeleteButtonClick()'>Delete<br/>Selected</button>", "orderable":false},
{ "title": "Effective Date"},
{ "title": "Item Number" },
]
Secondly i want to be able to call a custom JavaScript method on click of the header, something like function ApplySort(some Column identifier).
Its in ApplySort() function that i'll call the external web service which has like 101 constraints to the way one calls it. So i would like the JavaScript function to be able to recognize the column header on which click has happened and i'll take it forward from there.
How do i do this??
Answers
DataTables doesn't use the name space
sorting
(is that in the documentation somewhere?). Just unbind theclick
event without a namespace.Hmmm - I don't think there is a way to do that directly. You can write a custom sort method which DataTables will call itself internally when needed, but there is no way to have an external source sorting the data and redrawing the table.
Allan