Fix bug where download CSV icon would disappear on web interface after refreshing table data

This commit is contained in:
Dion Moult
2025-01-30 18:55:05 +11:00
parent 4e17a2d6de
commit 2ad48aba36
@@ -269,13 +269,7 @@ function addTableElement(blenderId, csvData, filename) {
},
});
var downloadCsv = $('<a><i class="fa-solid fa-file-csv"></i></a>')
.css("margin-left", "10px")
.css("cursor", "pointer");
tableTitle.append(downloadCsv);
downloadCsv.on("click", function () {
table.download("csv", "data.csv");
});
createDownloadIcon(blenderId);
table.on("rowSelected", function (row) {
var index = row.getIndex(); // the guid of the object
@@ -301,6 +295,18 @@ function addTableElement(blenderId, csvData, filename) {
});
}
function createDownloadIcon(blenderId) {
const table = Tabulator.findTable("#table-" + blenderId)[0];
const tableTitle = $("#title-" + blenderId);
var downloadCsv = $('<a><i class="fa-solid fa-file-csv"></i></a>')
.css("margin-left", "10px")
.css("cursor", "pointer");
tableTitle.append(downloadCsv);
downloadCsv.on("click", function () {
table.download("csv", "data.csv");
});
}
// Function to update table and filename
function updateTableElement(blenderId, csvData, filename) {
// check if the headers are the same
@@ -329,6 +335,7 @@ function updateTableElement(blenderId, csvData, filename) {
}
}
$("#title-" + blenderId).text(filename);
createDownloadIcon(blenderId);
}
}