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

[Solved] Hide rows in a 1 level hierarchy Grid

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nuno
Top achievements
Rank 1
Nuno asked on 22 Sep 2009, 02:33 PM

 

Hi all,

I've a RadGrid with one detailTable level.

My goal is to when editing one row in the detailTable, the other rows (not selected) should disappear,
 as well as the only visible row in the Main Grid should be the parent row (wich is actually expanded)

I tryed the code below but it's not working.

            foreach (GridDataItem dataItem in RadGrid1.Items)  
            {  
                if (RadGrid1.EditItems.Count > 0)  
                {  
                    if (!dataItem.Expanded)  
                    {  
                        dataItem.Visible = false;  
                    }  
                    else   
                    {  
                        foreach (GridDataItem item in RadGrid1.MasterTableView.Items[0].ChildItem.NestedTableViews[0].Items)  
                        {  
                            if (item != RadGrid1.EditItems[0])  
                            {  
                                item.Visible = false;                                  
                            }                                                              
                        }  
                    }                     
                }    
            } 


Any help is very appreciated.

Nuno Sénica.


 

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Sep 2009, 05:04 AM
Hi Nuno,

Try the following code snippet and see whether it helps.

C#:
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    if (RadGrid1.EditItems.Count > 0) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item != RadGrid1.EditItems[0]) 
            { 
                item.Visible = false
            } 
            foreach (GridDataItem itemDetail in item.ChildItem.NestedTableViews[0].Items) 
            { 
                if (!itemDetail.IsInEditMode) 
                { 
                    itemDetail.Visible = false
                    itemDetail.Display = false
                } 
            } 
        } 
    } 

-Shinu.
0
Nuno
Top achievements
Rank 1
answered on 23 Sep 2009, 09:56 AM

Hi Shinu,

Your code is almost perfect. What happens is that all rows in the Detail Grid are not visible, and I need the selected row (for edition) to be the only visible row in the Detail Grid.

Let me know what you think.

Thank you.

Nuno Sénica.
Tags
Grid
Asked by
Nuno
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nuno
Top achievements
Rank 1
Share this question
or