cancel
Showing results for 
Search instead for 
Did you mean: 
vg30
Sisense Team Member
Sisense Team Member

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:

vg30_0-1723133944793.png


After the script was targeted to the "Country" column:

vg30_1-1723133944756.png
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();
                });
            }
        });
    });
});

 

vg30_2-1723134009752.png


Check out this related content: 

Academy Course

Sisense Documentation

Rate this article:
Version history
Last update:
‎08-20-2024 01:56 PM
Updated by:
Contributors