jeudi 22 juin 2017

How to select all checkbox from datatable by one click

<th></th>
<td></td>

<script>
var table = $('#table').DataTable({
            "responsive": true,
  });

$('#select-all').on('click', function(){

            var rows = table.rows({ 'search': 'applied' }).nodes();
            $('input[type="checkbox"]', rows).prop('checked', this.checked);
        });

        $('#table tbody').on('change', 'input[type="checkbox"]', function(){

            if(!this.checked){
                var el = $('#select-all').get(0);           
                if(el && el.checked && ('indeterminate' in el)){
                    el.indeterminate = true;
                }
            }
        });
</script>

I tried above method but not working, any solution to fix it? Is there any mistake i have made? I think it should be working but i have no idea why cant select all when click on the 'select-all' checkbox



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sX6DKv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire