Changeset 24a616f for resources/assets/js/examples/pages
- Timestamp:
- 10/13/21 15:44:57 (3 years ago)
- Branches:
- develop, master
- Children:
- 120759b
- Parents:
- 194a359
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resources/assets/js/examples/pages/user-list.js
r194a359 r24a616f 5 5 'targets': 0, 6 6 'className': 'dt-body-center', 7 //'render': function (data, type, full, meta) {8 //return '<div class="custom-control custom-checkbox">' +9 //'<input type="checkbox" class="custom-control-input" id="customCheck' + meta.row + '">' +10 //'<label class="custom-control-label" for="customCheck' + meta.row + '"></label>' +11 //'</div>';12 //}7 'render': function (data, type, full, meta) { 8 return '<div class="custom-control custom-checkbox">' + 9 '<input type="checkbox" class="custom-control-input" id="customCheck' + meta.row + '">' + 10 '<label class="custom-control-label" for="customCheck' + meta.row + '"></label>' + 11 '</div>'; 12 } 13 13 }, 14 14 { 15 15 "orderable": false, 16 "targets": [ ]16 "targets": [0, 8] 17 17 } 18 18 ], … … 20 20 }); 21 21 22 //$(document).on('click', '#user-list-select-all', function () {23 //// Check/uncheck all checkboxes in the table24 //var rows = table.rows({'search': 'applied'}).nodes();25 //$('input[type="checkbox"]', rows)26 //.prop('checked', this.checked);27 //if (this.checked) {28 //$('input[type="checkbox"]', rows).closest('tr').addClass('tr-selected');29 //} else {30 //$('input[type="checkbox"]', rows).closest('tr').removeClass('tr-selected');31 //}32 //});33 // 34 //// Handle click on checkbox to set state of "Select all" control35 //$('#user-list tbody').on('change', 'input[type="checkbox"]', function () {36 //// If checkbox is not checked37 //if (!this.checked) {38 //var el = $('#user-list-select-all').get(0);39 //// If "Select all" control is checked and has 'indeterminate' property40 //if (el && el.checked && ('indeterminate' in el)) {41 //// Set visual state of "Select all" control42 //// as 'indeterminate'43 //el.indeterminate = true;44 //}45 //}46 //});47 // 48 //$(document).on('click', '.custom-control-input', function () {49 //if ($(this).prop('checked')) {50 //$(this).closest('td').closest('tr').addClass('tr-selected');51 //} else {52 //$(this).closest('td').closest('tr').removeClass('tr-selected');53 //}54 //});22 $(document).on('click', '#user-list-select-all', function () { 23 // Check/uncheck all checkboxes in the table 24 var rows = table.rows({'search': 'applied'}).nodes(); 25 $('input[type="checkbox"]', rows) 26 .prop('checked', this.checked); 27 if (this.checked) { 28 $('input[type="checkbox"]', rows).closest('tr').addClass('tr-selected'); 29 } else { 30 $('input[type="checkbox"]', rows).closest('tr').removeClass('tr-selected'); 31 } 32 }); 33 34 // Handle click on checkbox to set state of "Select all" control 35 $('#user-list tbody').on('change', 'input[type="checkbox"]', function () { 36 // If checkbox is not checked 37 if (!this.checked) { 38 var el = $('#user-list-select-all').get(0); 39 // If "Select all" control is checked and has 'indeterminate' property 40 if (el && el.checked && ('indeterminate' in el)) { 41 // Set visual state of "Select all" control 42 // as 'indeterminate' 43 el.indeterminate = true; 44 } 45 } 46 }); 47 48 $(document).on('click', '.custom-control-input', function () { 49 if ($(this).prop('checked')) { 50 $(this).closest('td').closest('tr').addClass('tr-selected'); 51 } else { 52 $(this).closest('td').closest('tr').removeClass('tr-selected'); 53 } 54 }); 55 55 });
Note:
See TracChangeset
for help on using the changeset viewer.