One dataTable affect another one!!

One dataTable affect another one!!

Mauro26Mauro26 Posts: 17Questions: 7Answers: 0

I'm having an issue, when ever i make this search i get the data normally but then i go to other two pages with datatables and it looks like they were affected with that filter cause i see this "Showing 0 to 0 of 0 entries ( 87 )". Anyone knows how to solve this?

$.fn.dataTable.ext.search.push(
            function(oSettings, aData, iDataIndex) {
                var oSettings = table.fnSettings();

if(bInvoiceDateUntil.isValid()){
                    if( (bDueDate.isValid() && bInvoiceDateUntil.isValid()) && (moment(dtDueDate).format('X')  <=  moment(dtInvoiceDateUntil).format('X') &&  aData[11] == "A") ) {
                        return true;
                    }
                    else{
                        return  false;
                    }
                        return false;

Regards!!

Replies

  • allanallan Posts: 64,026Questions: 1Answers: 10,555 Site admin

    Yes, the custom search functions are global, so you need to check that its the table you want to operate on. You can use oSettings.nTable.id to get the table id to check that:

    $.fn.dataTable.ext.search.push(
       function(oSettings, aData, iDataIndex) {
          if (oSettings.nTable.id !== 'myTable') {
             // Not interested
             return true;
          }
    
          .. otherwise do filtering
       }
    );
    

    Allan

  • Mauro26Mauro26 Posts: 17Questions: 7Answers: 0

    Hey allan,
    It was that, it's working perfect now.
    Thanks a lot!!
    Regards!

This discussion has been closed.