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

Expand Collapse function

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 02 Oct 2008, 05:34 PM

I want to implement radio buttons called “Expand/Collapse Selected” which would toggle depending on the state of what is selected.

 If you chose to Expand on the root (grandparent/first) level, it should drill in all the way.  If you are on the second level, it should expand all the way also, but just for that record. It should not expand the other records on the grid, only the selected (clicked) one.
How do I achieve this?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Oct 2008, 04:34 AM
Hi Eric,

I implemented the requested functionality on my side using a GridTemplateColumn with a radiobutton in its ItemTemplate. Here is the code I tired.

ASPX:
 <telerik:GridTemplateColumn UniqueName="TempCol" DataField="TimeSpan"  > 
                      <ItemTemplate> 
                          <asp:RadioButton ID="RadioButton1" AutoPostBack="true"  runat="server" OnCheckedChanged="RadioButton1_CheckedChanged" /> 
                      </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

CS:
 protected void RadioButton1_CheckedChanged(object sender, EventArgs e) 
    { 
        RadioButton radbtn = (RadioButton)sender; 
        GridDataItem item = (GridDataItem)radbtn.NamingContainer; 
        item.Expanded = true
        if (item.Expanded) 
        { 
            GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0]; 
            foreach (GridItem childitem in nestedView.Items) 
            { 
                childitem.Expanded = true
                if (childitem.Expanded) 
                { 
                    GridTableView nestedView2 = ((GridDataItem)childitem).ChildItem.NestedTableViews[0]; 
                    foreach (GridItem childitem2 in nestedView2.Items) 
                    { 
                        childitem2.Expanded = true
                    } 
                 
                } 
            } 
        
        } 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or