Advertisement
michaelyuen

Datatable

Feb 23rd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <!DOCType html>
  2. <head>
  3. <link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
  4. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  5. </head>
  6. <body>
  7.     <table id="datatablemasters" class="table table-striped table-bordered hover order-column" width="100%" cellspacing="0">
  8.             <thead>
  9.             <tr>
  10.                     <th>Country Sno</th>
  11.                     <th>Country Code</th>
  12.                     <th>Country Name</th>
  13.                     <th>Description</th>
  14.                     <th>Action</th>
  15.  
  16.             </tr>
  17.             </thead>
  18.     </table>
  19. <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
  20. <script>
  21.     $(document).ready(function(){
  22.                 $('#datatablemasters').dataTable( {
  23.                     "bProcessing": true,
  24.                     "ajax": 'post.php',
  25.                     dom: 'Bfrtip',
  26.                     buttons: ['csv', 'excel', 'pdf'],
  27.                     responsive: true,
  28.                     "columnDefs": [ {"targets": [0],"visible": false,"searchable": false},
  29.                                                 {width: 100, targets: 4}]
  30.                 });
  31.         });
  32. </script>
  33. </body>
  34. </html>
  35.  
  36. // post.php
  37.  
  38. <?php
  39.     $array = [['Country Sno1','Country Code1','Country Name1','Description1','Action1'],
  40.     ['Country Sno2','Country Code2','Country Name2','Description2','Action2'],
  41.     ['Country Sno3','Country Code3','Country Name3','Description3','Action3'],
  42.     ['Country Sno4','Country Code4','Country Name4','Description4','Action4']];
  43.     $data = ['data'=>$array];
  44.     echo json_encode($data);
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement