Improvements for parameteric part table (#4940)

- Initially only display columns which have data
This commit is contained in:
Oliver 2023-06-01 16:09:13 +10:00 committed by GitHub
parent 2c58b2fd36
commit cb0f0e34d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2025,6 +2025,7 @@ function loadParametricPartTable(table, options={}) {
switchable: true,
sortable: true,
filterControl: 'input',
visible: false,
});
}
}
@ -2053,6 +2054,9 @@ function loadParametricPartTable(table, options={}) {
uniqueId: 'pk',
onLoadSuccess: function(response) {
// Display columns as we receive data from them
let activated_columns = [];
// Data may be returned paginated, in which case we preference response.results
var data = response.results || response;
@ -2061,7 +2065,14 @@ function loadParametricPartTable(table, options={}) {
// Make each parameter accessible, based on the "template" columns
row.parameters.forEach(function(parameter) {
row[`parameter_${parameter.template}`] = parameter.data;
let col_name = `parameter_${parameter.template}`;
row[col_name] = parameter.data;
// Display the column if it is not already displayed
if (!activated_columns.includes(col_name)) {
activated_columns.push(col_name);
$(table).bootstrapTable('showColumn', col_name);
}
});
data[idx] = row;