Capturing user clicks on column headers
Capturing user clicks on column headers
Krishna
Posts: 3Questions: 0Answers: 0
I have a use case, when the user applies a filter criteria, results get displayed on the datatable (sorting, server side processing turned on)
I would like to distinguish between a filter submission and user (for sorting) clicks on column headers.
Is there a property which is turned on only when the user clicks on column headers ?
I would be then able to capture this information server side and decide on the source of invocation.
I would like to distinguish between a filter submission and user (for sorting) clicks on column headers.
Is there a property which is turned on only when the user clicks on column headers ?
I would be then able to capture this information server side and decide on the source of invocation.
This discussion has been closed.
Replies
Allan
Tried unbinding the click on the header
var table = $('#table').dataTable(options);
$('#table > thead > tr > th').each(function(key, value) {
$(value).unbind('click.DT', function() {
console.log("unbound");
});
});
I can still click and sort on the headers.
I was looking for a sort event to unbind it but i could find the following
$(oSettings.oInstance).trigger('sort', oSettings);
but the above triggers after successful sorting
Thoughts where i am going wrong.
-- Bind to click.DT
-- if it gets originated from the header element (with visible sort style), publish an event to inform the subscribers listening to.
Before server invocation
-- bind to the above event that we published above
-- In the callback of event, massage information to the existing data that will be sent when xhr gets invoked
Thus when the user clicks on the filter, the custom event will not get triggered whereas clicking on the column header (only sortable ones) will invoke the same.