gundambison

datatable02-views

Aug 25th, 2018
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2. //this is demo_datatable view
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6.     <head>
  7.         <meta charset="utf-8">
  8.         <link href="<?= base_url(); ?>media/css/jquery.dataTables.css" rel="stylesheet" />
  9.     </head>
  10.     <body>
  11.         <h1>PROVINCE</h1>
  12.         <div style="margin-left: 10px; width: 90%;">
  13.             <table class="dt_table" >
  14.                 <thead>
  15.                     <tr>
  16.                         <th>Number</th>
  17.                         <th>Kode</th>
  18.                         <th>Name</th>
  19.                         <th>Action</th>
  20.                     </tr>
  21.                 </thead>
  22.                 <tbody>
  23.                     <?php
  24.                     for ($i = 1; $i < 2; $i++) {
  25.                         ?>
  26.                         <tr>
  27.                             <td><?= $i; ?></td>
  28.                             <td>Code <?= $i; ?></td>
  29.                             <td>Name for <?= $i; ?></td>
  30.                             <td><button>Edit</button></td>
  31.                         </tr>
  32.                         <?php
  33.                     }
  34.                     ?>
  35.                 </tbody>
  36.  
  37.             </table>
  38.         </div>
  39.         <script src='<?= base_url(); ?>media/js/jquery1.11.3.js'></script>
  40.         <script src='<?= base_url(); ?>media/js/datatables.min.js'></script>
  41.         <script>
  42.             var table;
  43.             var url_target = "<?= site_url('demo/ajax_data'); ?>";
  44.             $(document).ready(function () {
  45.  
  46.                 //datatables clasic
  47.                 //table = $('.dt_table').DataTable();
  48.                 table = $('.dt_table').DataTable({"processing": true, //Feature control the processing indicator.
  49.                     "serverSide": true, //Feature control DataTables' server-side processing mode.
  50.                     "order": [], //Initial no order.// Load data for the table's content from an Ajax source
  51.                     "ajax": {
  52.                         "url": url_target,
  53.                         "type": "POST"
  54.                     },
  55.  
  56.                     //Set column definition initialisation properties.
  57.  
  58.                     "columns": [
  59.                         {"orderable": false},
  60.                         {},
  61.                         {},
  62.                         {"orderable": false}
  63.                     ],
  64.                     "lengthMenu": [[3, 5, 7, 10, 25, 50, 62], ["Tiga", "Lima", 7, 10, 25, 50, "62"]],
  65.  
  66.                 });
  67.  
  68.             });
  69.         </script>
  70.     </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment