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

Showing rows expanded in heirarchical grid

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 04 Feb 2009, 09:44 AM
Hi,

I am using a heirarchical grid which is nested till level 3 and want to show some rows in the inner detail grids to be expanded. I wish to do this programmatically if the rows match some criteria.

I tried the following but it does not seem to work-
protected void Page_PreRender(object sender, EventArgs e)  
{  
    foreach (GridDataItem masterItem in RadGrid1.MasterTableView.Items)  
    {  
        // loop through the element under each category  
        foreach (GridDataItem detailitem1 in masterItem.ChildItem.NestedTableViews[0].Items)  
        {  
            foreach (GridDataItem detailitem2 in detailitem1.ChildItem.NestedTableViews[0].Items)  
            {  
                if (...my criteria..)  
                {  
                    detailitem1.Expanded = true;  
                    //also tried the one below  
                    //RadGrid1.SelectedIndexes.Add(masterItem.ItemIndex, detailitem1.ItemIndex, detailitem2.ItemIndex);  
                }  
            }  
        }  
    }  

Can someone please help...

Thanks,
- Manoj

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Feb 2009, 01:25 PM
Hi Manoj,

I guess you want to expand the innermost table based on some condition in second details table. I can see that you looped through the inner detail table and tried to expand the second. Here I tried to loop through the element of second table and expanded inner table based on the criteria.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
{  
    foreach (GridDataItem masterItem in RadGrid1.MasterTableView.Items)    
    {  
        if (masterItem.Expanded)  
        {  
            // loop through the element under each category    
            foreach (GridDataItem detailitem1 in masterItem.ChildItem.NestedTableViews[0].Items)  
            {  
                if (detailitem1["OrderID"].Text == "10643"// check the criteria  
                     detailitem1.Expanded= true;                     
            }  
        }  
    }  

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