This is a migrated thread and some comments may be shown as answers.

Hide/UnHide RadGrid columns

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
myrad
Top achievements
Rank 1
myrad asked on 08 Dec 2010, 11:23 PM
Hi,

I have 10 GridBoundColumns in RadGrid1. I want to hide and unhide columns from outside grid. Let say I have 2 buttons when user click on first button i want to hide first five columns and when user click on second button i want to hide last five columns.

Can you please tell me how do i do this?

Many Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 09 Dec 2010, 05:44 AM
Hello Myrad,


Iterate through the columns and set the Visible property to accordingly to show/hide columns. Sample code is here.

Code:
protected void Button2_Click(object sender, EventArgs e)
{
    foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
    {
        column.Visible = column.OrderIndex < 5;
    }
    RadGrid1.MasterTableView.Rebind();
}
protected void Button3_Click(object sender, EventArgs e)
{
    foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
    {
        column.Visible = column.OrderIndex >= 5;
    }
    RadGrid1.MasterTableView.Rebind();
}



-Shinu.
Tags
Grid
Asked by
myrad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or