How to remove click event from header cell

How to remove click event from header cell

sjw01sjw01 Posts: 67Questions: 36Answers: 1

I followed this guide: https://datatables.net/examples/api/multi_filter_select.html and added dropdown search fields on 3 of my columns.

I moved the dropdowns into the header and set the default value to the cell title - Perfect.

However... There is a click event on the entire header cell. On the columns where I have added a search filter, I want to remove the click handler (BUT, I want to leave it active on the aria controls)

Is this possible?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @sjw01 ,

    You can use standard jQuery stuff for that - so something like

    $('#example thead th').off('click')
    

    or you can narrow down the selector, if you want specific columns:

    $('#example thead th:eq(2)').off('click')
    

    Cheers,

    Colin

  • sjw01sjw01 Posts: 67Questions: 36Answers: 1

    Thanks.

    That takes the click off the head but also off the aria controls.

    I assume I need to re-assign that click to only the aria controls which I assume is not possible given that the controls are a background image inside the cell?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi again,

    The best bet is to have a second row in the header, something like this: http://live.datatables.net/duhahuso/1/edit

    There's no easy, clean way to do it on the single row unfortunately.

    Cheers,

    Colin

This discussion has been closed.