Advertisement
zawaruddin

Contoh Checkbox dalam Datatable

Jul 7th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ini untuk datatablenya
  2. var local = $('#data_table_mhs').DataTable();
  3.  
  4. // ini untuk submitnya
  5. // class check_mhs untuk checkbox isi data
  6. // class checkAll untuk checkbox trigger select all
  7.  
  8. $('#add-mhs-form').submit(function(e){
  9.     if($(".check_mhs:checkbox:checked").length > 0){  // cek jika ada checkbox data yg d select
  10.         var pos = local.$('input, select').serializeArray();  // ini buat kirim data mana aja nilai checkbox yg d kirim sesuai yg d pilih
  11.         $.post("<?php echo site_url('mhs/sendData')?>", pos, function( data ) { ... });
  12.     }
  13. });
  14.  
  15. $(".checkAll").click(function () {
  16.     $('#data_table_mhs tbody input[type="checkbox"], input[class="checkAll"]').prop('checked', this.checked);
  17.  });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement