source: public/assets/js/examples/pages/user-list.js@ 4b7e2d3

develop
Last change on this file since 4b7e2d3 was 4b7e2d3, checked in by beratkjufliju <kufliju@…>, 3 years ago

bug fixes, edited export, added fileSeeder for DB testing

  • Property mode set to 100644
File size: 2.2 KB
Line 
1$(document).ready(function () {
2 var table = $('#user-list').DataTable({
3 'columnDefs': [
4 {
5 'targets': 0,
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 // }
13 },
14 {
15 "orderable": false,
16 "targets": [0, 2]
17 },
18 ],
19 'order': [1, 'asc'],
20 buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
21 });
22
23 $(document).on('click', '#user-list-select-all', function () {
24 // Check/uncheck all checkboxes in the table
25 var rows = table.rows({'search': 'applied'}).nodes();
26 $('input[type="checkbox"]', rows)
27 .prop('checked', this.checked);
28 if (this.checked) {
29 $('input[type="checkbox"]', rows).closest('tr').addClass('tr-selected');
30 } else {
31 $('input[type="checkbox"]', rows).closest('tr').removeClass('tr-selected');
32 }
33 });
34
35 // Handle click on checkbox to set state of "Select all" control
36 $('#user-list tbody').on('change', 'input[type="checkbox"]', function () {
37 // If checkbox is not checked
38 if (!this.checked) {
39 var el = $('#user-list-select-all').get(0);
40 // If "Select all" control is checked and has 'indeterminate' property
41 if (el && el.checked && ('indeterminate' in el)) {
42 // Set visual state of "Select all" control
43 // as 'indeterminate'
44 el.indeterminate = true;
45 }
46 }
47 });
48
49 $(document).on('click', '.custom-control-input', function () {
50 if ($(this).prop('checked')) {
51 $(this).closest('td').closest('tr').addClass('tr-selected');
52 } else {
53 $(this).closest('td').closest('tr').removeClass('tr-selected');
54 }
55 });
56});
Note: See TracBrowser for help on using the repository browser.