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

RadGrid Expand

3 Answers 201 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asra
Top achievements
Rank 1
Asra asked on 26 May 2009, 12:59 PM
hi All,

         Iam dynamically binding the grid. I have a RAdGrid with tabs in it . Iam binidng data to the tabs dynamically. In one of the tab i have RadGrid. Iam using RAdGRid1_ItemCreated event to bind the Grid. In the event i want to know wheather the grid is expanded or not.

Iam uisng the property and the geting the values like
bool exp= e.item.expanded;

but it always returns false wheather i click on expand colum or collpase.

Pls help me out to how to do this

its very urgent..

Asra

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 May 2009, 01:41 PM
Hello Asra,

You can try the following code in the PreRender event of the grid to check if the row is expanded or not:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
      foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            {                 
                //  code here  
            } 
        } 
    } 

Thanks
Princy.
0
Pravin Magdum
Top achievements
Rank 1
answered on 06 May 2010, 11:09 AM
i have nestedviewtemplate and it contains usercontrol , and it load all for 10 rows every time postback occurs

i want to load usercontrol only for single row which user want expand 

is there any expand event  so that i can mange to load only single usercontrol instead of all every time 

thnx in advance 

0
Shinu
Top achievements
Rank 2
answered on 06 May 2010, 01:14 PM

Hi,

One suggestion in your case is setting the Visible property of grid in user control to "False" initially. And set the Visible proeprty when expanding the item. Invoke the Rebind() method after setting the Visible property to fire the NeedDataSource event to populate the grid whenever its showing on page.

In ItemCommand event of parent grid, you can access the grid control placed iin uc and set the Visible property to "True" as shown below. Here is an example.

C#:

 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)   
{   
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)   
    {        
        Usercontrol uc = (Usercontrol)((GridDataItem)e.Item).ChildItem.FindControl("Usercontrol1"); // Access the UC  
        RadGrid gridinUC = (RadGrid)uc.FindControl("RadGridinUC");   
        if (!e.Item.Expanded)   
        {   
            gridinUC.Visible = true;   
            gridinUC.Rebind();   
        }   
        else   
        {   
            gridinUC.Visible = false;   
        }   
    }    
}  

Regards,

Shinu.

Tags
Grid
Asked by
Asra
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pravin Magdum
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or