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

Hide Leaf Node Grid

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shivan
Top achievements
Rank 1
Shivan asked on 23 Oct 2010, 02:19 PM
Hello Telerik team,

Please give me the C# code to hide the leaf node grid in a self referencing hierarchical grid

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Oct 2010, 08:35 AM
Hello Shiva,

I hope the following logic will help you in hiding the leaf nodes in self referencing hierarchy.

CS:
ArrayList list = new ArrayList();
protected
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    CreateExpandCollapseButton(e.Item, "EmployeeID");
 
    if (e.Item is GridDataItem)
    {
        string value = ((GridDataItem)e.Item)["ReportsTo"].Text;
        if (!list.Contains(value))
        {
            list.Add(value);
        }
    }
}
 
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach ( GridDataItem item in RadGrid1.Items )
    {
        if (!list.Contains(item["EmployeeID"].Text))
        {
            item.Visible = false;
        }
    }
}

The above example is based on the demo : Self-referencing Hierarchy



-Shinu.
Tags
General Discussions
Asked by
Shivan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or