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

Radgrid of two level

1 Answer 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawson
Top achievements
Rank 1
Dawson asked on 04 Nov 2013, 12:37 PM
Hi,
 I am having a hierarchy radgrid of two level. I wanted a header button near to the column headers, where clicking on it expands all the rows. How to achieve this. Anyone can provide me with a sample.?
 
Thankyou.
Dawson

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 04 Nov 2013, 12:42 PM
Hi Dawson,

Please try the following code snippet to have a Header button for Expand/Collapse.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        GridHeaderItem headerItem = e.Item as GridHeaderItem;
        ImageButton imgBtn = new ImageButton();
        imgBtn.ID = "imgExpandCollapse";
        if (RadGrid1.MasterTableView.HierarchyDefaultExpanded)
        {
            imgBtn.ImageUrl = "~/collapse.png";
        }
        else
        {
            imgBtn.ImageUrl = "~/expand.png";
        }
        headerItem["ExpandColumn"].Controls.Add(imgBtn);
        imgBtn.Click += new ImageClickEventHandler(imgBtn_Click);
    }
}
 
void imgBtn_Click(object sender, ImageClickEventArgs e)
{
    RadGrid1.MasterTableView.HierarchyDefaultExpanded = !RadGrid1.MasterTableView.HierarchyDefaultExpanded;
    RadGrid1.Rebind();
}

Thanks,
Princy
Tags
Grid
Asked by
Dawson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or