Skip to content

Change the visibility of the Grid View's columns on the client without making a round trip to the server.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-web-forms-grid-hide-a-column-on-the-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - How to hide a grid column on the client

This example demonstrates how to change the visibility of the Grid View's columns on the client without making a round trip to the server. Check or uncheck the Unit Price Column check box to show or hide the Unit Price column.

Hide a grid column on the client

Overview

Follow the steps below to change a column's visibility on the client.

1 Apply a CSS class to all cells of a column

A column can include the following cells:

Apply your CSS class to the CssClass property of every cell in a column:

<dx:ASPxGridView ID="gvProducts" runat="server" AutoGenerateColumns="False" DataSourceID="dsProducts" KeyFieldName="ProductID">
    <Columns>
        <!-- ... -->
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="4">
            <HeaderStyle CssClass="unitPriceColumn" />
            <EditCellStyle CssClass="unitPriceColumn" />
            <CellStyle CssClass="unitPriceColumn" />
            <FilterCellStyle CssClass="unitPriceColumn" />
            <FooterCellStyle CssClass="unitPriceColumn" />
            <GroupFooterCellStyle CssClass="unitPriceColumn" />
        </dx:GridViewDataTextColumn>
    </Columns>
</dx:ASPxGridView>

2 Specify the display property of the CSS class

The display property of the CSS class specifies the display behavior of an element. Set this property to none to hide the column or set it to table-cell to show the column.

This example uses a jQuery CSS selector to change the display property value.

<script type="text/javascript">
    function SetUnitPriceColumnVisibility(visible) {
        unitPriceColumnVisible = visible;
        var disp = visible ? 'table-cell' : 'none';
        $('td.unitPriceColumn').css('display', disp);
    }
</script>

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Change the visibility of the Grid View's columns on the client without making a round trip to the server.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •