devbenjamin

app.js

Feb 29th, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     //Server-side
  3.     //$('#example').DataTable( {
  4.     //    "processing": true,
  5.     //    "serverSide": true,
  6.     //    "ajax": "server_processing.php"
  7.     //} );
  8.  
  9.     // Setup - add a text input to each footer cell
  10.     $('#example tfoot th').each( function () {
  11.         var title = $(this).text();
  12.         $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
  13.     } );
  14.  
  15.     // DataTable
  16.     var table = $('#example').DataTable();
  17.  
  18.     // Apply the search
  19.     table.columns().every( function () {
  20.         var that = this;
  21.  
  22.         $( 'input', this.footer() ).on( 'keyup change', function () {
  23.             if ( that.search() !== this.value ) {
  24.                 that
  25.                     .search( this.value )
  26.                     .draw();
  27.             }
  28.         } );
  29.     } );
  30. } );
Advertisement
Add Comment
Please, Sign In to add comment