如何在筛选之前隐藏行并在数据表上过滤后显示行?

时间:2017-01-11 15:43:22

标签: jquery codeigniter datatables

我想在过滤进程之前隐藏表中的行,当我过滤数据时,我希望数据会自动显示在表的行中。我使用的是datatables和codeigniter,这里是HTML代码:

<label>Filter Venue</label>
   <?php
      echo "
       <select class='form-control' id='field' required>
         <option value='' disabled selected>Pilih Venue</option>";
          foreach ($venue as $v) {  
          echo "<option value='".$v['venue']."'>".$v['venue']."</option>";
          }
          echo"
           </select>";
   ?>

<table id="kursi" class="table table-bordered table-striped">
  <thead>
  <tr>
    <th>Venue</th>
    <th>No Kursi</th>
    <th>Kelas</th>
    <th>Status</th>
  </tr>
  </thead>
  <tbody>
  <?php foreach($data as $k) { ?>
  <tr>
    <td><?php echo $k['venue']?></td>
    <td><?php echo $k['no_kursi']?></td>
    <td><?php echo $k['kelas']?></td>
    <td><?php echo $k['status']?></td>
  </tr>
  <?php } ?>
  </tbody>
</table>


这里是jquery数据表代码:

 $(document).ready(function() {
 $('#kursi').DataTable( {
     "paging":   true,
     "info":     true,
     "ordering" : true,
     "oSearch": {"bSmart": false},
     "sPaginationType": "full_numbers"
 } );

 var oTable;
 oTable = $('#kursi').dataTable();

 $('#field').change( function() { 
       oTable.fnFilter($(this).val()); 
  });

});

0 个答案:

没有答案