This commit is contained in:
jokob-sk
2025-08-24 09:21:13 +10:00
parent afbcf5985f
commit 0146ae7c30

View File

@@ -685,11 +685,17 @@ function initializeDatatable (status) {
}, },
"dataSrc": function (res) { "dataSrc": function (res) {
json = res["data"]; console.log("Raw response:", res);
// Set the total number of records for pagination const json = res["data"];
json.recordsTotal = json.devices.count || 0;
json.recordsFiltered = json.devices.count || 0;
// Set the total number of records for pagination at the *root level* so DataTables sees them
res.recordsTotal = json.devices.count || 0;
res.recordsFiltered = json.devices.count || 0;
// console.log("recordsTotal:", res.recordsTotal, "recordsFiltered:", res.recordsFiltered);
// console.log("tableRows:", tableRows);
// Return only the array of rows for the table
return json.devices.devices.map(device => { return json.devices.devices.map(device => {
// Convert each device record into the required DataTable row format // Convert each device record into the required DataTable row format
// Order has to be the same as in the UI_device_columns setting options // Order has to be the same as in the UI_device_columns setting options
@@ -703,10 +709,10 @@ function initializeDatatable (status) {
device.devFirstConnection || "", device.devFirstConnection || "",
device.devLastConnection || "", device.devLastConnection || "",
device.devLastIP || "", device.devLastIP || "",
device.devIsRandomMac || "", // Custom logic for randomized MAC device.devIsRandomMac || "",
device.devStatus || "", device.devStatus || "",
device.devMac || "", // hidden device.devMac || "",
device.devIpLong || "", // IP orderable device.devIpLong || "",
device.rowid || "", device.rowid || "",
device.devParentMAC || "", device.devParentMAC || "",
device.devParentChildrenCount || 0, device.devParentChildrenCount || 0,
@@ -731,7 +737,6 @@ function initializeDatatable (status) {
for (let index = 0; index < tableColumnOrder.length; index++) { for (let index = 0; index < tableColumnOrder.length; index++) {
newRow.push(originalRow[tableColumnOrder[index]]); newRow.push(originalRow[tableColumnOrder[index]]);
} }
return newRow; return newRow;
}); });
} }