Removing a Column from Telerik RadGrid at Runtime

If you need to remove a column from a Telerik RadGrid at runtime, subscribe to the grid’s DataBound event, find the column by its unique name, and set its display property to false. This is the correct way to do this without breaking the filter functionality. For a long time I was subscribing to the grid’s ItemDataBound event and hiding each dataitem for the column- only now did I realize that the filter was broken by doing it that way.

Example:

protected void rgPartDispositionHistory_DataBound(object sender, EventArgs e)
    {
        rgPartDispositionHistory.MasterTableView.Columns
        .FindByUniqueName("PeopleSoftId").Display = isTwtc;
    }

I hope this helps someone!

Happy Coding,

Tom Hundley
Elegant Software Solutions, LLC

What are your thoughts?

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.