How to remove an entire column on a table widget with a custom widget script
How to remove an entire column on a table widget with a custom widget script
Disclaimer: Please note that this blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their environment before deploying them to ensure that the solutions proffered function as desired in their environment. For the avoidance of doubt, the content of this blog post is provided to you "as-is" and without warranty of any kind, express, implied, or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this post incorporates custom coding, which is outside the Sisense product development environment and is, therefore, not covered by Sisense warranty and support services.
You can use the following widget script, which can hide the specific column from the Table / Table with Aggregation widget, for example below.
Before the script was applied, table view:
After the script was targeted to the "Country" column:
Script to use:
widget.on('ready', () => {
element.on('draw.dt', () => {
// Define the column names to hide
var columnsToHide = [''];
// Iterate through each column in the thead
element.find("thead th").each((index, th) => {
var columnName = $(th).text().trim();
// Check if the column name is in the list of columns to hide
if (columnsToHide.includes(columnName)) {
// Hide the entire column in thead
$(th).hide();
// Hide the entire column in each tbody row
element.find("tbody tr").each((rowIndex, row) => {
$(row).children().eq(index).hide();
});
}
});
});
});
Check out this related content:
Academy Course
Sisense Documentation
Published 08-20-2024
vg30
Sisense Employee
Joined May 31, 2024