Ashok Gurram
Ashok Gurram

Reputation: 631

how to change "searchable" columns dynamically in datatable?

I need to implement a functionality in DataTables to set the searchable property for columns to true / false dynamically.

https://datatables.net/

I have implemented this in one way.

dataObject.settings()[0].aoColumns[index].bSearchable = true;                   
dataObject.clear();
dataObject.rows.add(data);
dataObject.draw();

It is only working by clearing all data in the DataTable and rebinding but this is not the correct way.

It should update the search property dynamically. It should update without clearing the data.

Are there any other options when using DataTables to change the searchable property dynamically and without rebinding?

Upvotes: 8

Views: 2212

Answers (1)

inDream
inDream

Reputation: 1277

After changed bSearchable, call invalidate() to clear the cache.

dataObject.rows().invalidate();

Ref: DataTables - dynamically set columns searchable

Upvotes: 1

Related Questions