Datatables selector ignore element?

Datatables selector ignore element?

Andrew1178Andrew1178 Posts: 24Questions: 6Answers: 0

I have been looking here: https://datatables.net/reference/option/select.selector to try to set my custom datatable select selector.

I would like to add a selector which ignores anchor links, I would've thought that this would work:

 select: {
        style: "multi",
        selector: 'td:not(a)'
    }

but it does not.

Does anyone know how to set the datatables selector to ignore anchor links?

JSFiddle: https://jsfiddle.net/1Lej7q3w/6/

This question has an accepted answers - jump to answer

Answers

  • Andrew1178Andrew1178 Posts: 24Questions: 6Answers: 0

    Also I know this is unrelated but I would really appreciate it if someone could answer my question here: https://datatables.net/forums/discussion/41896/issue-recalculating-column-widths-after-ajax-call#Comment_109158

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    The td:not(a) selector isn't going to work since it is selecting all td elements and then removing the a tags (which of course there isn't any since only td elements were selected).

    There isn't actually a selector that can do what you are looking for in Select. However, what you can do is use the user-select event to check if an a was clicked on, and if so, then ignore the event.

    Updated fiddle.

    Allan

  • Andrew1178Andrew1178 Posts: 24Questions: 6Answers: 0

    Thanks Allan for the response, this fixed my issue. Please can you look at my comment in this thread and let me know if there is a planned update to the extension package to recalculate the responsive columns after an ajax request as the selected answer in the thread is to modify the source code while you work on inserting the code into the correct place.

This discussion has been closed.