because of the filters that I apply in a dataTable affects others?

because of the filters that I apply in a dataTable affects others?

emmanuel921218emmanuel921218 Posts: 11Questions: 4Answers: 0
edited November 2019 in Free community support

I have three dataTables but I only apply the filters to one, but when I start the page the other tables start filtered.

I share how I initialize the tables. The first is in which I apply the filters, and the second is one that is affected.

1.-

var genealogytable = $('#genealogy').DataTable({
     
      //stateSave: true,
        destroy: true,
        processing: true,
       // ajax: "reloadTab/?idsponsor=" + idsponsor + "&&period=" + period + "&&type=" + typee,
        ajax: "http://mynikkentest.nikkenlatam.com/reloadTab/?idsponsor=" + idsponsor + "&&period=" + period + "&&type=" + typee,
        deferRender: true,

        columns: [
            {
                data: null,
                className: "center",
                defaultContent: '<td> <p><label> <input type="checkbox" id="emailGenealog[]" name="email[]" class="check_mailGenealogy" onclick="mailRowGen(this.parentNode.parentNode.parentNode.parentNode.id)" name="countries[]" value="" /><span></span></label></p> </td>'
            },
            {data: 'Line'},
            {data: 'Level'},

2.-

     $('#signupNew').DataTable({
     
      //stateSave: true,
        destroy: true,
        processing: true,
        ajax: "signupNew/{{ $ids }}",
        deferRender: true,

        columns: [
                {data: 'SignupDate'},
                {data: 'associateid'},
                {data: 'associatename'},
                {data: 'SponsorName'},
                {data: 'PV'},
                {data: 'GV'},
                {data: 'OV'},
                {data: 'QOVOPL'},
                {data: 'QOVOPSL'},
        ]
    });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    The first is in which I apply the filters, and the second is one that is affected.

    How are you applying the filters? There is nothing in those table declarations that would cause any interference.

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • emmanuel921218emmanuel921218 Posts: 11Questions: 4Answers: 0

    I'm sorry I'm new, and I don't know how to do that, I'll read what is due

    $ ('# updatefilter'). click (function () {
    genealogytable.draw ();
    });

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    That's not applying a filter, it's just doing a draw - so we'd really need to see this to be able to progress it.

  • emmanuel921218emmanuel921218 Posts: 11Questions: 4Answers: 0

    sorry, this is

    $('#updatefilterDonw').keyup( function() {
    genealogytable.draw();
    } );

     $.fn.dataTable.ext.search.push(
    
        function( settings, data, dataIndex ) {
            var min = parseInt( $('#minLevelPPV').val(), 10 );
            var max = parseInt( $('#maxLevelPPV').val(), 10 );
            var lv = parseFloat( data[15] ) || 0; // use data for the level column
    
            if ( ( isNaN( min ) && isNaN( max ) ) ||
                 ( isNaN( min ) && lv <= max ) ||
                 ( min <= lv   && isNaN( max ) ) ||
                 ( min <= lv   && lv <= max ) )
            {
                return true;
            }
            return false;
        }
      );
    
  • emmanuel921218emmanuel921218 Posts: 11Questions: 4Answers: 0
    edited November 2019

    Solve the problem this way

    // setup an array of the ids of tables that should be allowed
    var allowFilter = ['productTable'];

    $.fn.dataTableExt.afnFiltering.push(function(oSettings, aData, iDataIndex) {

    // check if current table is part of the allow list
    if ( $.inArray( oSettings.nTable.getAttribute('id'), allowFilter ) == -1 )
    {
       // if not table should be ignored
       return true;
    }
    

    });

This discussion has been closed.