raul_lfc - 1.10 - modifying searchable option

raul_lfc - 1.10 - modifying searchable option

allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
edited February 2014 in General
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 !

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    edited February 2014
    Mortifying the parameters in the settings object has never been supported - they are considered to be private.

    There is no public API to change the searchable flag for a column in any version of DataTables after initialisation, sorry.

    Allan
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    Thanks Allan for Reply.
    I wonder how that would work on dataTable 1.9.4 but not in dataTable 1.10 ?
    Is there any other alternative ?
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    > wonder how that would work on dataTable 1.9.4 but not in dataTable 1.10 ?

    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
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    Hi Allan, I spend few days to look in the Datatable 1.10.0 beta 2 library file to check the functionality related to this as compared to Datatable 1.9.4, but I didn't got anything. please suggest on which function we have to look for ? and what exactly difference between Datatable 1.10 and 1.4 in terms of the my issue.
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    I'll try to look into this sometime next week, however, as I say, this is not a public API and therefore not supported.

    Allan
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    edited March 2014
    Hi 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
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Fair enough - good to hear you have a work around for your use case.

    Allan
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    Hi 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
This discussion has been closed.