Close
Angular React Web Components Blazor Web Components
Premium

Web Components Hierarchical Grid Column Hiding

The Ignite UI for Web Components has a built-in column hiding UI, which can be used through the Web Components Hierarchical Grid toolbar to change the visible state of the columns. Developers have the flexibility to define the Column Hiding UI anywhere within the page as needed. The Web Components Hierarchical Grid Column Hiding feature is especially useful when one wants to decrease the size of the grid and to eliminate the need for tabbing through redundant fields.

Web Components Hierarchical Grid Column Hiding Example

Hierarchical Grid Setup

Let’s start by creating our IgcHierarchicalGrid and binding it to our data. We will also enable both filtering and sorting for the columns.

<igc-hierarchical-grid auto-generate="false" primary-key="ID" allow-filtering="true" name="hierarchicalGrid1" id="hierarchicalGrid1">
    <igc-column field="Artist" header="Artist" data-type="string" sortable="true"></igc-column>
    <igc-column field="Photo" header="Photo" data-type="image"></igc-column>
    <igc-column field="Debut" header="Debut" data-type="number" hidden="true"></igc-column>
    <igc-column field="GrammyNominations" header="Grammy Nominations" data-type="number" sortable="true" hidden="true"></igc-column>
    <igc-column field="GrammyAwards" header="Grammy Awards" data-type="number" sortable="true"> </igc-column>
</igc-hierarchical-grid>

Toolbar’s Column Hiding UI

The built-in Column Hiding UI is placed inside an Dropdown in the IgcHierarchicalGrid‘s toolbar. We can show/hide the Column Hiding UI by using this exact dropdown.

For this purpose all we have to do is set both the GridToolbarActions and the GridToolbarHiding inside of the IgcHierarchicalGrid.

The IgcHierarchicalGrid provides us with some useful properties when it comes to using the toolbar’s column hiding UI.

By using the Title and Prompt properties, we will set the title and filter prompt that are displayed inside the dropdown in the toolbar.

You can see the result of the code from above at the beginning of this article in the Web Components Column Hiding Example section.

Disable hiding of a column

We can easily prevent the user from being able to hide columns through the column hiding UI by simply setting their disableHiding property to true.

<igc-hierarchical-grid>
    <igc-column field="Artist" data-type="string" sortable="true" disable-hiding="true"></igc-column>
    <igc-column field="GrammyAwards" data-type="string" sortable="true" disable-hiding="true"></igc-column>

    <igc-row-island>
        <igc-column field="Album" data-type="string" sortable="true" disable-hiding="true"></igc-column>
    </igc-row-island>
</igc-hierarchical-grid>

Styling

The grid could be further customized by setting some of the available CSS variables. In order to achieve that, we will use a class that we will first assign to the grid:

<igc-hierarchical-grid class="hierarchical-grid"></igc-hierarchical-grid>

Then set the related CSS variables for the related components. We will apply the styles also only on the igx-column-actions, so the rest of the grid is unaffected:

.hierarchical-grid {
    /* Main Column Actions styles */
    --ig-column-actions-background-color: #292826;
    --ig-column-actions-title-color: #ffcd0f;

    /* Checkbox styles */
    --ig-checkbox-tick-color: #292826;
    --ig-checkbox-label-color: #ffcd0f;
    --ig-checkbox-empty-color: #ffcd0f;
    --ig-checkbox-fill-color: #ffcd0f;

    /* Input styles */
    --ig-input-group-idle-text-color: white;
    --ig-input-group-filled-text-color: #ffcd0f;
    --ig-input-group-focused-text-color: #ffcd0f;
    --ig-input-group-focused-border-color: #ffcd0f;
    --ig-input-group-focused-secondary-color: #ffcd0f;

    /* Buttons styles */
    --ig-button-foreground: #292826;
    --ig-button-background: #ffcd0f;
    --ig-button-hover-background: #404040;
    --ig-button-hover-foreground: #ffcd0f;
    --ig-button-focus-background: #ffcd0f;
    --ig-button-focus-foreground: black;
    --ig-button-focus-visible-background: #ffcd0f;
    --ig-button-focus-visible-foreground: black;
    --ig-button-disabled-foreground: #ffcd0f;
}

Demo

API References

Additional Resources

Our community is active and always welcoming to new ideas.