raul_lfc - 1.10 - modifying searchable option
raul_lfc - 1.10 - modifying searchable option
Moved from the 1.10.0-beta.1 release thread: http://datatables.net/forums/discussion/19349/
Hi Allan,
I am dynamically adding and removing column. So want to make column that is hidden as non searchable, and column that will be shown as searchable.
I was able to make individual column searchable/non searchable dynamically using following code using datatable 1.9.4
[code]
var oTable=$('#example').dataTable();
oTable.fnSettings().aoColumns[0].bSearchable=false;
[/code]
Above code works fine in datatable 1.9.4 ,but not in datatable 1.10.0
Please see link http://live.datatables.net/ePIK/4/edit
in above example I have imported datatable 1.9.4 and so if we try to search contents of the 1st column, Result set noe are shown (meets my requirements), but when we replace with datatable 1.10.0 , and search content of the 1st column then it will returns the matched values.
Is there any way to make particular column searchable/non Searchable in datatable1.10.0 dynamically?
Thanks in advance !
Hi Allan,
I am dynamically adding and removing column. So want to make column that is hidden as non searchable, and column that will be shown as searchable.
I was able to make individual column searchable/non searchable dynamically using following code using datatable 1.9.4
[code]
var oTable=$('#example').dataTable();
oTable.fnSettings().aoColumns[0].bSearchable=false;
[/code]
Above code works fine in datatable 1.9.4 ,but not in datatable 1.10.0
Please see link http://live.datatables.net/ePIK/4/edit
in above example I have imported datatable 1.9.4 and so if we try to search contents of the 1st column, Result set noe are shown (meets my requirements), but when we replace with datatable 1.10.0 , and search content of the 1st column then it will returns the matched values.
Is there any way to make particular column searchable/non Searchable in datatable1.10.0 dynamically?
Thanks in advance !
This discussion has been closed.
Replies
There is no public API to change the searchable flag for a column in any version of DataTables after initialisation, sorry.
Allan
I wonder how that would work on dataTable 1.9.4 but not in dataTable 1.10 ?
Is there any other alternative ?
Because I've changed some of the internals of DataTables for optimisation in 1.10. The private parameters are there so I can do that without effecting the public API.
> Is there any other alternative ?
You'd probably need to modify DataTables core to add that ability.
Allan
Allan
Just to update, I went through code and i found why things were not working in datatable 1.10.0.
In dataTable 1.10 we are saving data in cache on initial load thereafter searching,filtering made on the cached data (this is what I understand), this improves lot of performance of dataTable. So even if i made changes like [code]oTable.fnSettings().aoColumns[0].bSearchable=false;[/code], its not being updated to Data settings which is cached.
where as in datatable 1.9.4 in function _fnFilterCustom we are searching on the array having bSearchable true, using
var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
so it was working in earlier version.
In new datatable in function _fnFilterData,it checks whether data is already cached or not?
using if ( ! row._aFilterData ).
[code]
function _fnFilterData ( settings )
{
var columns = settings.aoColumns;
var column;
var i, j, ien, jen, filterData, cellData, row;
var fomatters = DataTable.ext.type.search;
var wasInvalidated = false;
for ( i=0, ien=settings.aoData.length ; i
Allan
Just encounter one issue in above approach. I thought it might be dataTable bug.
so starting one more thread at
http://datatables.net/forums/discussion/19822/error-while-doing-invalidate-the-rows-using-rows-invalidate-having-pagination-#Item_1