1"use strict"; 2var KTDatatablesExtensionButtons = function() { 3 4 var initTable1 = function() { 5 6 // begin first table 7 var table = $('#kt_table_1').DataTable({ 8 responsive: true, 9 // Pagination settings 10 dom: `<'row'<'col-sm-6 text-left'f><'col-sm-6 text-right'B>> 11 <'row'<'col-sm-12'tr>> 12 <'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>`, 13 14 buttons: [ 15 'print', 16 'copyHtml5', 17 'excelHtml5', 18 'csvHtml5', 19 'pdfHtml5', 20 ], 21 columnDefs: [ 22 { 23 targets: 6, 24 render: function(data, type, full, meta) { 25 var status = { 26 1: {'title': 'Pending', 'class': 'kt-badge--brand'}, 27 2: {'title': 'Delivered', 'class': ' kt-badge--danger'}, 28 3: {'title': 'Canceled', 'class': ' kt-badge--primary'}, 29 4: {'title': 'Success', 'class': ' kt-badge--success'}, 30 5: {'title': 'Info', 'class': ' kt-badge--info'}, 31 6: {'title': 'Danger', 'class': ' kt-badge--danger'}, 32 7: {'title': 'Warning', 'class': ' kt-badge--warning'}, 33 }; 34 if (typeof status[data] === 'undefined') { 35 return data; 36 } 37 return '<span class="kt-badge ' + status[data].class + ' kt-badge--inline kt-badge--pill">' + status[data].title + '</span>'; 38 }, 39 }, 40 { 41 targets: 7, 42 render: function(data, type, full, meta) { 43 var status = { 44 1: {'title': 'Online', 'state': 'danger'}, 45 2: {'title': 'Retail', 'state': 'primary'}, 46 3: {'title': 'Direct', 'state': 'success'}, 47 }; 48 if (typeof status[data] === 'undefined') { 49 return data; 50 } 51 return '<span class="kt-badge kt-badge--' + status[data].state + ' kt-badge--dot"></span> ' + 52 '<span class="kt-font-bold kt-font-' + status[data].state + '">' + status[data].title + '</span>'; 53 }, 54 }, 55 ], 56 }); 57 58 }; 59 60 var initTable2 = function() { 61 62 // begin first table 63 var table = $('#kt_table_2').DataTable({ 64 responsive: true, 65 66 buttons: [ 67 'print', 68 'copyHtml5', 69 'excelHtml5', 70 'csvHtml5', 71 'pdfHtml5', 72 ], 73 processing: true, 74 serverSide: true, 75 ajax: { 76 url: 'https://keenthemes.com/metronic/themes/themes/metronic/dist/preview/inc/api/datatables/demos/server.php', 77 type: 'POST', 78 data: { 79 // parameters for custom backend script demo 80 columnsDef: [ 81 'OrderID', 'Country', 'ShipCity', 82 'ShipAddress', 'CompanyAgent', 'CompanyName', 'Status', 'Type',], 83 }, 84 }, 85 columns: [ 86 {data: 'OrderID'}, 87 {data: 'Country'}, 88 {data: 'ShipCity'}, 89 {data: 'ShipAddress'}, 90 {data: 'CompanyAgent'}, 91 {data: 'CompanyName'}, 92 {data: 'Status'}, 93 {data: 'Type'}, 94 ], 95 columnDefs: [ 96 { 97 targets: 6, 98 render: function(data, type, full, meta) { 99 var status = { 100 1: {'title': 'Pending', 'class': 'kt-badge--brand'}, 101 2: {'title': 'Delivered', 'class': ' kt-badge--danger'}, 102 3: {'title': 'Canceled', 'class': ' kt-badge--primary'}, 103 4: {'title': 'Success', 'class': ' kt-badge--success'}, 104 5: {'title': 'Info', 'class': ' kt-badge--info'}, 105 6: {'title': 'Danger', 'class': ' kt-badge--danger'}, 106 7: {'title': 'Warning', 'class': ' kt-badge--warning'}, 107 }; 108 if (typeof status[data] === 'undefined') { 109 return data; 110 } 111 return '<span class="kt-badge ' + status[data].class + ' kt-badge--inline kt-badge--pill">' + status[data].title + '</span>'; 112 }, 113 }, 114 { 115 targets: 7, 116 render: function(data, type, full, meta) { 117 var status = { 118 1: {'title': 'Online', 'state': 'danger'}, 119 2: {'title': 'Retail', 'state': 'primary'}, 120 3: {'title': 'Direct', 'state': 'success'}, 121 }; 122 if (typeof status[data] === 'undefined') { 123 return data; 124 } 125 return '<span class="kt-badge kt-badge--' + status[data].state + ' kt-badge--dot"></span> ' + 126 '<span class="kt-font-bold kt-font-' + status[data].state + '">' + status[data].title + '</span>'; 127 }, 128 }, 129 ], 130 }); 131 132 $('#export_print').on('click', function(e) { 133 e.preventDefault(); 134 table.button(0).trigger(); 135 }); 136 137 $('#export_copy').on('click', function(e) { 138 e.preventDefault(); 139 table.button(1).trigger(); 140 }); 141 142 $('#export_excel').on('click', function(e) { 143 e.preventDefault(); 144 table.button(2).trigger(); 145 }); 146 147 $('#export_csv').on('click', function(e) { 148 e.preventDefault(); 149 table.button(3).trigger(); 150 }); 151 152 $('#export_pdf').on('click', function(e) { 153 e.preventDefault(); 154 table.button(4).trigger(); 155 }); 156 157 }; 158 159 return { 160 161 //main function to initiate the module 162 init: function() { 163 initTable1(); 164 initTable2(); 165 }, 166 167 }; 168 169}(); 170 171jQuery(document).ready(function() { 172 KTDatatablesExtensionButtons.init(); 173});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.