From f8bcce2b4cb64a69f35b6bdce7fe085613ff5707 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 23 Jan 2026 17:27:20 -0600 Subject: DataTables: Only set the "data" and "columns" options if not empty. To prevent the utility function from breaking the way DataTables works when you provide an already populated table, only set the data and columns options if the user actually provides values for them. --- uploader/static/js/datatables.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uploader/static/js/datatables.js b/uploader/static/js/datatables.js index 82fd696..e111c11 100644 --- a/uploader/static/js/datatables.js +++ b/uploader/static/js/datatables.js @@ -35,8 +35,6 @@ var buildDataTable = (tableId, data = [], columns = [], userSettings = {}) => { lengthMenu: "", info: "" }, - data: data, - columns: columns, drawCallback: (settings) => { $(this[0]).find("tbody tr").each((idx, row) => { var arow = $(row); @@ -53,7 +51,9 @@ var buildDataTable = (tableId, data = [], columns = [], userSettings = {}) => { } var theDataTable = $(tableId).DataTable({ ...defaultSettings, - ...userSettings + ...userSettings, + ...(data.length == 0 ? {} : {data: data}), + ...(columns.length == 0 ? {} : {columns: columns}) }); theDataTable.on("select", (event, datatable, type, cell, originalEvent) => { datatable.rows({selected: true}).nodes().each((node, index) => { -- cgit 1.4.1