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

Collapse/Expand Hierarchy Grid Row based on Drop Down List click

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Loi
Top achievements
Rank 1
Loi asked on 23 Jul 2008, 04:42 PM
Hi,

I have a grid with 3 detail tables hierarchy.  I wonder if anyone can show me how to collapse and expand a detail table based on a drop down list click.  In each of the row or item in my grid, I have a "Yes/No" drop down list. If a user select "yes", then I want to expand the detail table.  If they select "no", then I want to collapse the table. 

Thanks again.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jul 2008, 06:11 AM
Hello Loi,

Check out the following code snippet to implement the required scenario.
aspx:
<MasterTableView  DataSourceID="SqlDataSource1"
                 
                <Columns> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn"
                <ItemTemplate> 
                    <asp:DropDownList AutoPostBack="true" ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
                    <asp:ListItem Text="No" Value="No"></asp:ListItem>   
                    <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>                                        
                    </asp:DropDownList> 
                </ItemTemplate> 
                </telerik:GridTemplateColumn>                    
                </Columns>                            
</MasterTableView> 

cs:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        DropDownList ddl = (DropDownList)sender; 
        GridDataItem data = (GridDataItem)ddl.NamingContainer; 
        if (ddl.Text == "Yes") 
        { 
            data.Expanded = true
        } 
        else 
        { 
            data.Expanded = false
        } 
    } 

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