File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/assets/custom/js/camplus-datatable.js
Back
// Remove the formatting to get integer data for summation function intVal ( i ) { return typeof i === 'string' ? i.replace(/[\$,]/g, '')*1 : typeof i === 'number' ? i : 0; }; function column_sum(i) { // Total over all pages var api=$( '#data_table' ).DataTable(); console.log(api) total = api .column( i ) .data() .reduce( function (a, b) { return intVal(a) + intVal(b); }, 0 ); return total; } function column_length() { // Total over all pages var api=$( '#data_table' ).DataTable(); total = api .data() .length return total; } function checkboxEnable(enable) { if (enable) { return [ { // set default column settings 'orderable': true, 'targets': [0] }, { "searchable": true, "targets": [0] }, { "className": "dt-right", //"targets": [2] } ] } else { return [ { // set default column settings 'orderable': false, 'targets': [0] }, { "searchable": false, "targets": [0] }, { "className": "dt-right", //"targets": [2] } ] } } function initTable(enable = false) { // var chinese = { // "processing": "處理中...", // "loadingRecords": "載入中...", // "lengthMenu": "顯示 _MENU_ 項結果", // "zeroRecords": "沒有符合的結果", // "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項", // "infoEmpty": "顯示第 0 至 0 項結果,共 0 項", // "infoFiltered": "(從 _MAX_ 項結果中過濾)", // "infoPostFix": "", // "search": "搜尋:", // "paginate": { // "first": "第一頁", // "previous": "上一頁", // "next": "下一頁", // "last": "最後一頁" // }, // "aria": { // "sortAscending": ": 升冪排列", // "sortDescending": ": 降冪排列" // } // }; // var english = { // "sEmptyTable": "No data available in table", // "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries", // "sInfoEmpty": "Showing 0 to 0 of 0 entries", // "sInfoFiltered": "(filtered from _MAX_ total entries)", // "sInfoPostFix": "", // "sInfoThousands": ",", // "sLengthMenu": "Show _MENU_ entries", // "sLoadingRecords": "Loading...", // "sProcessing": "Processing...", // "sSearch": "Search:", // "sZeroRecords": "No matching records found", // "oPaginate": { // "sFirst": "First", // "sLast": "Last", // "sNext": "Next", // "sPrevious": "Previous" // }, // "oAria": { // "sSortAscending": ": activate to sort column ascending", // "sSortDescending": ": activate to sort column descending" // } // }; // var currentLang = english $('#data_table').DataTable({ //Use the plugin from: https://github.com/jhyland87/DataTables-Hide-Empty-Columns //add the plugin to: assets/custom/datatables/HideEmptyColumns/dataTables.hideEmptyColumns.min.js hideEmptyCols: true, // Internationalisation. For more info refer to http://datatables.net/manual/i18n // if($.cookie("language") == "ch") { // currentLang = chinese; // } else { // currentLang = english; // } // Or you can use remote translation file //"language": { // url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json' //}, // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). // So when dropdowns used the scrollable div should be removed. //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // "oLanguage": currentLang, "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie. "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] // change per page values here ], // set the initial value "pageLength": 20, "pagingType": "bootstrap_full_number", "columnDefs": checkboxEnable(enable), "order": [ [1, "asc"] ], initComplete: function () { var table_completed = $('#data_table').DataTable(); $("#data_table thead tr:first th").each( function ( i, v ) { if($(v).data('filter') == 1){ var select = $('<select class="'+$(this).data('type')+' select2"><option value="">- All -</option></select>') .appendTo( $(this).empty() ) .on( 'change', function () { var val = $(this).val(); table_completed.column( i ) .search( val ? '^'+$(this).val()+'$' : val, true, false ) .draw(); } ); table_completed.column( i ).data().unique().sort().each( function ( d, j ) { var val = $('<div/>').html(d).text(); select.append( '<option value="' + val + '">' + val + '</option>' ) }); } else{ if(i==0) { } } }); } // set first column as a default sort by asc }); var table = $('#data_table').dataTable(); table.find('.group-checkable').change(function () { var set = jQuery(this).attr("data-set"); var checked = jQuery(this).is(":checked"); jQuery(set).each(function () { if (checked) { $(this).prop("checked", true); $(this).parents('tr').addClass("active"); } else { $(this).prop("checked", false); $(this).parents('tr').removeClass("active"); } }); }); table.on('change', 'tbody tr .checkboxes', function () { $(this).parents('tr').toggleClass("active"); }); } function captionBadge() { if ( $.fn.DataTable.isDataTable( '#data_table' ) ) { var cols = column_length(); $('.caption').first().append(' <span class="badge datatables_count"> '+ cols + '</span>') } else { console.log('waiting 300 for init'); setTimeout(captionBadge,1000); } }
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.13 |
proxy
|
phpinfo
|
Settings