Advertisement
ekobudiyanto

Untitled

Apr 15th, 2020
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.73 KB | None | 0 0
  1. /*
  2.  * DataTables - Tables
  3.  */
  4.  
  5.  
  6. $(function () {
  7.  
  8. /*  $('#multi-select').DataTable({
  9.     responsive: true,
  10.     "columnDefs": [{
  11.       "orderable": false,
  12.       "targets": [0, -1]
  13.     }],
  14.   });*/
  15.  
  16.   $('#multi-select').DataTable({
  17.     "responsive": true,
  18.     "lengthMenu": [
  19.       [10, 25, 50, -1],
  20.       [10, 25, 50, "All"]
  21.     ]
  22.   });
  23. });
  24.  
  25. // Datatable click on select issue fix
  26. $(window).on('load', function () {
  27.   $(".dropdown-content.select-dropdown li").on("click", function () {
  28.     var that = this;
  29.     setTimeout(function () {
  30.       if ($(that).parent().parent().find('.select-dropdown').hasClass('active')) {
  31.         // $(that).parent().removeClass('active');
  32.         $(that).parent().parent().find('.select-dropdown').removeClass('active');
  33.         $(that).parent().hide();
  34.       }
  35.     }, 100);
  36.   });
  37. });
  38.  
  39. var checkbox = $('#multi-select tbody tr th input');
  40. var selectAll = $('#multi-select .select-all');
  41.  
  42. // Select A Row Function
  43.  
  44. $(document).ready(function () {
  45.   checkbox.on('click', function () {
  46.     $(this).parent().parent().parent().toggleClass('selected');
  47.   });
  48.  
  49.   checkbox.on('click', function () {
  50.     if ($(this).attr("checked")) {
  51.       $(this).attr('checked', false);
  52.     } else {
  53.       $(this).attr('checked', true);
  54.     }
  55.   });
  56.  
  57.  
  58.   // Select Every Row
  59.  
  60.   selectAll.on('click', function () {
  61.     $(this).toggleClass('clicked');
  62.     if (selectAll.hasClass('clicked')) {
  63.       $('#multi-select tbody tr').addClass('selected');
  64.     } else {
  65.       $('#multi-select tbody tr').removeClass('selected');
  66.     }
  67.  
  68.     if ($('#multi-select tbody tr').hasClass('selected')) {
  69.       checkbox.prop('checked', true);
  70.  
  71.     } else {
  72.       checkbox.prop('checked', false);
  73.     }
  74.   })
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement