1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| const Datatables = { basic: function (id, tableOption, info) { let table = $(id).DataTable({ responsive: true, language: { info: info ? info : ' _TOTAL_ 개의 데이터가 있습니다.', }, columns: tableOption ? tableOption.columns : null, order: [[0, 'asc']], });
return table; }, order: function (id, tableOption, num, info) { let table = $(id).DataTable({ responsive: true, language: { info: info ? info : ' _TOTAL_ 개의 데이터가 있습니다.', }, columns: tableOption ? tableOption.columns : null, columnDefs: [ { orderable: true, className: 'reorder', targets: 0 }, { orderable: true, className: 'reorder', targets: num }, { orderable: false, targets: '_all' }, ], order: [[num, 'desc']], });
return table; }, rowsAdd: function (table, url, param) { table.clear();
$.ajax({ url: url, type: 'POST', data: JSON.stringify(param), contentType: 'application/json', success: function (data) { table.rows.add(data).draw(); table.responsive.recalc(); }, }); }, refresh: function (table, data) { table.clear(); table.rows.add(data).draw(); }, };
|