Skip to content

Commit 4a79261

Browse files
committed
feat(admin.js): Added csk.ui.dataTable().
Also bumped version to `1.3.15`
1 parent 3f2aedd commit 4a79261

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

js/admin.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,31 @@
313313
*/
314314
selectOn: function(e) {
315315
document.body.style.userSelect = "";
316+
},
317+
/**
318+
* DataTable.
319+
* @since 3.9.8
320+
*/
321+
dataTable: function (selector, options) {
322+
if (typeof $.fn.DataTable === "undefined") {
323+
console.error("Please load DataTables before using 'csk.ui.dataTable'.");
324+
return;
325+
}
326+
const defaults = {
327+
processing: true,
328+
serverSide: true,
329+
ajax: {
330+
url: $(selector).data("source"),
331+
type: "POST"
332+
},
333+
order: [[0, 'asc']],
334+
pageLength: csk.config.perPage,
335+
columnDefs: [{
336+
targets: "no-sort",
337+
orderable: false
338+
}]
339+
};
340+
return $(selector).DataTable($.extend(true, {}, defaults, options));
316341
}
317342
};
318343

@@ -625,21 +650,6 @@
625650
});
626651
}
627652

628-
/**
629-
* Datatables.
630-
* @since 2.16
631-
*/
632-
if (typeof $.fn.DataTable !== "undefined") {
633-
$(".datatables").each(function() {
634-
$(this).DataTable({
635-
columnDefs: [{
636-
targets: 'no-sort',
637-
orderable: false
638-
}]
639-
});
640-
});
641-
}
642-
643653
/**
644654
* Bootstrap 4 File Upload.
645655
* @since 2.18

0 commit comments

Comments
 (0)