let table; if (typeof adminc === "undefined") { var adminc; adminc = 0; } if (typeof initc === "undefined") { var initc; initc = 1; } if (typeof hidesearch === "undefined") { var hidesearch; hidesearch = [100]; } if (typeof hidesearch === "undefined") { var cstmbuttons; cstmbuttons = []; } if (typeof pageLength === "undefined") { var pageLength; pageLength = -1; } if (typeof cstmdom === "undefined") { var cstmdom; cstmdom = "flBrtip"; } if (typeof columndefs === "undefined") { var columndefs; columndefs = ""; } if (typeof columnfilter === "undefined") { var columnfilter; columnfilter = ""; } if (typeof columnoptions === "undefined") { var columnoptions; columnoptions = ""; } $('#filterrow th').each(function (i) { let title = $('#datatable thead th').eq($(this).index()).text(); if (hidesearch.includes($(this).index())) { } else if (columnfilter.includes($(this).index())) { $(this).html(''); } else { $(this).html(''); } }); table = $('#datatable').DataTable({ fixedHeader: { header: true, headerOffset: $('#topnav').outerHeight() }, lengthMenu: [ [25, 50, 100, -1], [25, 50, 100, 'All'] ], pageLength: pageLength, columnDefs: [ columndefs ], "language": { "url": "/datatables/json/german.json?v2" }, orderCellsTop: true, stateSave: true, stateDuration: 60 * 60 * 24 * 30, "initComplete": function () { $('.dt-search').append(''); $('.dt-search').addClass('d-inline-block'); $.each(cstmbuttons, function (index, value) { $('.dt-buttons').append(value); }); $('#dt-length-0').addClass('form-control-sm'); $('#clear_cookie').click(function () { $('#filterrow input').val(''); $('#filterrow select').val(''); table.search('').columns().search('').draw(); }); if (initc === 2) { $('.buttons-excel').closest('div').append('
'); $('.buttons-excel').closest('div').append(''); $('.buttons-excel').closest('div').append(''); $('.buttons-excel').closest('div').append(''); } else if (initc === 3) { $('.buttons-excel').closest('div').append(''); $('.buttons-excel').closest('div').append(''); if (adminc===1) { $('.buttons-excel').closest('div').prepend(''); } } }, layout: { topStart: { search: { placeholder: '' }, buttons: [ { extend: 'excelHtml5', text: 'XLSX Export', className: 'btn-success margina d-none d-lg-block', exportOptions: { columns: ['th:not(:last-child)'], format: { body: function (data, row, column, node) { console.log(data); data = $('' + data + '
').text(); return $.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data; } } } } ] }, topEnd: { pageLength: true } } }); $(window).scroll(function () { var height = $(window).scrollTop(); if (height > 200) { if ($('#filterrow').is(':visible')) { $('#filterrow').hide(); } } else { if ($('#filterrow').is(':hidden')) { $('#filterrow').show(); } } }); $('#filterrow').on('keyup', 'input', function () { table .column($(this).data('index')) .search(this.value) .draw(); }); $('.selectsearch').change(function () { table .column($(this).data('index')) .search(this.value) .draw(); }); let state = table.state.loaded(); if (state) { table.columns().eq(0).each(function (colIdx) { var colSearch = state.columns[colIdx].search; if (colSearch.search) { $('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search); } }); table.draw(); }