filtering and table-id

filtering and table-id

FicosFicos Posts: 88Questions: 22Answers: 0

Filtering my table with this function:

$.fn.dataTable.ext.search.push( function ( settings, searchData, index, rowData, counter ) {
    if(
      (((btnArchief==0) && (searchData[1]=='0')) || ((btnArchief==1) && (searchData[1]=='1'))) &&
      (((btnRelatie==0) && (searchData[2]=="0")) || ((btnRelatie==1) && (searchData[2]=="1")))
    ){
    return true;
    }
    return false;
  };
});

When there are more than 1 table on the page, this filtering will occur on ALL tables. So I need to identify each table. In Version 9 i could identify the table with :

if ( oSettings.nTable.id == 'client05' ) {

so I presume that the table id will be found in settings.
Can you please tell me where I can find the values of "settings" and how to use them?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin

    You can do that in 1.10 as well.

    Its not ideal I know, but that should still work.

    Allan

  • FicosFicos Posts: 88Questions: 22Answers: 0

    It doesn't work:

    $.fn.dataTable.ext.search.push( function ( settings, searchData, index, rowData, counter ) {
      if(oSettings.nTable.id == 'client'){
        if(
          (((btnArchief==0) && (searchData[1]=='0')) || ((btnArchief==1) && (searchData[1]=='1'))) &&
          (((btnRelatie==0) && (searchData[2]=="0")) || ((btnRelatie==1) && (searchData[2]=="1")))
        ){
        return true;
        }
        return false;
      }
      return true;
    });
    
    $(document).ready(function() {
      var table = $('#client').DataTable( {});
    });
    

    Still I wonder where I can find the information about 'settings' in the search functions.

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Have you checked your browser's console? I'd be surprised if there isn't an error there stating that oSettings is undefined. It is - you've called the settings parameter settings in the argument list. They should match.

    Still I wonder where I can find the information about 'settings' in the search functions.

    You won't find it anywhere. For the most part the settings object is private. This is the one exception since that information can't easily be obtained via the API. That will change with the next major update.

    Allan

This discussion has been closed.