Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change "searchable" columns dynamically in datatable?

Tags:

datatables

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?

like image 574
Ashok Gurram Avatar asked Jan 21 '17 10:01

Ashok Gurram


1 Answers

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

dataObject.rows().invalidate();

Ref: DataTables - dynamically set columns searchable

like image 114
inDream Avatar answered Sep 17 '22 15:09

inDream