Set column.searchable = true after DataTable initialisation

Set column.searchable = true after DataTable initialisation

guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

Hi everyone,

I've initialised my dataTable with the following setting:

columnDefs: [
                    { targets: 1, type: 'diacritics-neutralise', searchable: true },
                    { targets: '_all', searchable: false}
                ],

But depending on some user interactions in my application, I'd like to make column(0) searchable.

Is it possible?

Thank you,

Guilherme

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,587

    Hi @guilhermemaranhao ,

    Unfortunately not. Some properties (and behaviours) can only be set when the table is first initialised, and searchability is one of those.

    What you could do perhaps, is when the user causes that interaction, is to reinitialise the table with the new searchable value. You could also pass in destroy so all other properties would be the same. A side-effect would be searching, paging and ordering would be reset, but if it was important to maintain those, you could include stateSave,

    Hope that helps,

    Cheers,

    Colin

  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    Thanks, @colin ! I'll try it

This discussion has been closed.