144 lines
4.6 KiB
JavaScript
Executable File
144 lines
4.6 KiB
JavaScript
Executable File
/*!
|
|
* Start Bootstrap - SB Admin v7.0.3 (https://startbootstrap.com/template/sb-admin)
|
|
* Copyright 2013-2021 Start Bootstrap
|
|
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
|
|
*/
|
|
//
|
|
// Scripts
|
|
//
|
|
|
|
|
|
$(function() {
|
|
let copyButtonTrans = 'Copy'
|
|
let csvButtonTrans = 'CSV'
|
|
let excelButtonTrans = 'Excel'
|
|
let pdfButtonTrans = 'PDF'
|
|
// let printButtonTrans = '{{ trans('global.datatables.print') }}'
|
|
let colvisButtonTrans = 'Columns'
|
|
let selectAllButtonTrans = 'Select All'
|
|
let selectNoneButtonTrans = 'Deselect All'
|
|
|
|
let languages = {
|
|
'en': 'https://cdn.datatables.net/plug-ins/1.10.19/i18n/English.json'
|
|
};
|
|
|
|
$.extend(true, $.fn.dataTable.Buttons.defaults.dom.button, {
|
|
className: 'btn'
|
|
})
|
|
$.extend(true, $.fn.dataTable.defaults, {
|
|
language: {
|
|
url: languages['{{ app()->getLocale() }}']
|
|
},
|
|
columnDefs: [
|
|
{
|
|
orderable: false,
|
|
className: 'select-checkbox',
|
|
targets: 0
|
|
},
|
|
{
|
|
orderable: false,
|
|
searchable: false,
|
|
targets: -1
|
|
}
|
|
],
|
|
select: {
|
|
style: 'multi+shift',
|
|
selector: 'td:first-child'
|
|
},
|
|
order: [],
|
|
scrollX: true,
|
|
pageLength: 100,
|
|
dom: "<'row'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-7'B><'col-sm-12 col-md-3'f>>" +
|
|
"<'row'<'col-sm-12'tr>>" +
|
|
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
|
// dom: '<lBfr>tip<"actions">',
|
|
buttons: [{
|
|
extend: 'selectAll',
|
|
className: 'btn-primary mr-1',
|
|
text: selectAllButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
},
|
|
action: function(e, dt) {
|
|
e.preventDefault()
|
|
dt.rows().deselect();
|
|
dt.rows({
|
|
search: 'applied'
|
|
}).select();
|
|
}
|
|
},
|
|
{
|
|
extend: 'selectNone',
|
|
className: 'btn-primary mr-1',
|
|
text: selectNoneButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
}
|
|
},
|
|
{
|
|
extend: 'copy',
|
|
className: 'btn-default mr-1',
|
|
text: copyButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
}
|
|
},
|
|
{
|
|
extend: 'csv',
|
|
className: 'btn-default mr-1',
|
|
text: csvButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
}
|
|
},
|
|
{
|
|
extend: 'excelHtml5',
|
|
className: 'btn-default mr-1',
|
|
text: excelButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible',
|
|
stripHtml: true
|
|
},
|
|
customize: function(xlsx,btnObj, tableInst) {
|
|
let sheet = xlsx.xl.worksheets['sheet1.xml'];
|
|
let cellIndexes = tableInst.cells(".bg-danger").indexes();
|
|
for (const cellIndex of cellIndexes) {
|
|
let tblRow = cellIndex['row']+3; // adjusted from 0 indexed
|
|
let tblCol = cellIndex['column']; // adjusted from 0 indexed
|
|
let xlCol = numberToLetters(tblCol);
|
|
let excelCell = xlCol+tblRow;
|
|
$('row c[r='+excelCell+']', sheet).attr( 's', '11' );
|
|
}
|
|
}
|
|
},
|
|
{
|
|
extend: 'pdfHtml5',
|
|
className: 'btn-default mr-1',
|
|
text: pdfButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
}
|
|
},
|
|
// {
|
|
// extend: 'print',
|
|
// className: 'btn-default',
|
|
// text: printButtonTrans,
|
|
// exportOptions: {
|
|
// columns: ':visible'
|
|
// }
|
|
// },
|
|
{
|
|
extend: 'colvis',
|
|
className: 'btn-default mr-1',
|
|
text: colvisButtonTrans,
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
$.fn.dataTable.ext.classes.sPageButton = '';
|
|
});
|
|
|
|
// console.log("Scripts");
|