how to disable sorting click event on table header children

how to disable sorting click event on table header children

andreafinaandreafina Posts: 3Questions: 2Answers: 0

Hi!

Based on the following example in https://datatables.net/examples/api/multi_filter.html I'm rendering my table header as input fields allowing custom filtering for each table column:

    $('#example thead th').each( function () { 
        var title = $('#example thead th').eq( $(this).index() ).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

However, currently sorting of the column is triggered on each click on a th node AND its children. This means each time I put the cursor to an input field the click triggers sorting of the column.
Is there a way to disable firing this event for the input field but leave it for the th node?
I've already tried the suggestions in http://datatables.net/forums/discussion/3638/disable-sorting-when-clicking-on-headers but they seem to be for a previous Datatables version.

$('.dataTables_scrollHead thead th').unbind('click.DT');

disables the click event for the whole th node, but I'm not sure how to use https://datatables.net/reference/api/order.listener() for changing the click handling.

Thx, for helping me out!

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.