From d1616a5e0e225dbedddf423ac3ec74a99a66d5cc Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 27 Jul 2022 18:29:51 +0000 Subject: Allow create_table to handle tables without row data provided as JSON (so it can also convert regular HTML tables drawn in the template --- wqflask/wqflask/static/new/javascript/create_datatable.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/create_datatable.js b/wqflask/wqflask/static/new/javascript/create_datatable.js index fc9530a5..2953655c 100644 --- a/wqflask/wqflask/static/new/javascript/create_datatable.js +++ b/wqflask/wqflask/static/new/javascript/create_datatable.js @@ -1,4 +1,4 @@ -create_table = function(tableId, tableData, columnDefs, customSettings) { +create_table = function(tableId, tableData = [], columnDefs = [], customSettings = {}) { loadDataTable(tableId=tableId, tableData=tableData, customSettings, firstRun=true) @@ -23,7 +23,6 @@ create_table = function(tableId, tableData, columnDefs, customSettings) { change_buttons() }); }, - "data": tableData, "columns": columnDefs, "sDom": "iti", "destroy": true, @@ -49,6 +48,10 @@ create_table = function(tableId, tableData, columnDefs, customSettings) { } } + if (tableData.length > 0){ + tableSettings["data"] = tableData + } + // Replace default settings with custom settings or add custom settings if not already set in default settings $.each(customSettings, function(key, value) { tableSettings[key] = value -- cgit v1.2.3