kwangu

Ajax Datatable initialization bootstrap 3

Jul 15th, 2022
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript" language="javascript" >  
  2.  $(document).ready(function(){  
  3.       var dataTable = $('#dtTable').DataTable({  
  4.            "processing":true,  
  5.            "serverSide":true,  
  6.            "order":[],  
  7.            "ajax":{  
  8.                 url:"<?php echo base_url() . 'controller/query_db'; ?>",  
  9.                 type:"POST"  
  10.            },  
  11.            "columnDefs":[{  
  12.                      "targets":[0, 3, 4],  
  13.                      "orderable":false,  
  14.                 },  
  15.            ],  
  16.            //lengthChange: true,
  17.            "dom": '<"pull-left"B><"pull-left"l><"pull-right"f>tp',
  18.            buttons: [{
  19.                 text: 'New Category',
  20.                 action: function ( e, dt, node, config ){
  21.                 location.href = 'category/cat_crud';
  22.                 }
  23.             },
  24.             'excel', 'colvis'
  25.         ],
  26.         lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
  27.        
  28.       });  
  29.       table.buttons().container()
  30.         .appendTo( '#dtTable_wrapper .col-sm-6:eq(0)');
  31.         //dropdown
  32.        
  33.  });  
  34.  </script>  
Add Comment
Please, Sign In to add comment