datatables Multi Column search filter when reload refresh Page lose column values

datatables Multi Column search filter when reload refresh Page lose column values

YounesZDYounesZD Posts: 2Questions: 1Answers: 0

Hello i have datatables with Multi Column search filter and Function bstatesave for save the search when reload the page the problem when i'm reload page i'm lose the value input

how i can show the value in column when reload refresh The Page

Before Reload/refresh page

After Reload/refresh page

Answers

  • YounesZDYounesZD Posts: 2Questions: 1Answers: 0

    Finaty i'm find soltuion :)

    $('#tableExample3 tfoot th').each( function () {
    var title = $('#tableExample3 thead th').eq( $(this).index() ).text();
    $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

    // DataTable
    
    
    // Restore state
    var state = table.state.loaded();
    if ( state ) {
      table.columns().eq( 0 ).each( function ( colIdx ) {
        var colSearch = state.columns[colIdx].search;
    
        if ( colSearch.search ) {
          $( 'input', table.column( colIdx ).footer() ).val( colSearch.search );
        }
      } );
    
      table.draw();
    }
    
    
    // Apply the search
    table.columns().eq( 0 ).each( function ( colIdx ) {
        $( 'input', table.column( colIdx ).footer() ).on( 'keyup change', function () {
            table
                .column( colIdx )
                .search( this.value )
                .draw();
        } );
    } );
    
This discussion has been closed.