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

[Solved] Crazy Grid Idea

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik Hinds
Top achievements
Rank 1
Erik Hinds asked on 10 Aug 2009, 08:13 PM
I'm looking to do a three level nested grid with the last detail table having a radiobuttonlist to filter the data.


-Hierarchy 1

   -Hierachy 2
 
Show All (6 Records)   Show X (3Records)   Show Y (2 Records)   Show Z (1 Record)
     -------------------Detail Table------------------


The radiobutton list is created on demand and on postback rebinds the data in the detail table based on a filter value.

Any examples of this out there?




1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Aug 2009, 05:52 AM
Hi Erik,

Try placing the RadioButtonList in the CommandItemTemplate of the third level Detail table and in its SelectedIndexChanged event you may try the following approach to achieve the desired functionality.

ASPX:
 
 <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="5" DataSourceID="SqlDataSource1" > 
 <MasterTableView   DataSourceID="SqlDataSource1"
         
                <Columns> 
                    ... 
                <DetailTables> 
                      <telerik:GridTableView runat="server" Caption="Detail"   Name="Detail"  DataSourceID="SqlDataSource2" > 
                       <Columns> 
                        ... 
                        <DetailTables> 
                          <telerik:GridTableView runat="server" CommandItemDisplay="Top" Caption="Detail2"   Name="Detail2"  DataSourceID="SqlDataSource3" > 
                            <CommandItemTemplate> 
                                <asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="true" RepeatDirection="Horizontal" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
                                  <asp:ListItem Text="Show All" Value="All" ></asp:ListItem> 
                                  <asp:ListItem Text="Show 3 records" Value="3" ></asp:ListItem> 
                                  <asp:ListItem Text="Show 2 records" Value="2" ></asp:ListItem> 
                                  <asp:ListItem Text="Show 1 record" Value="1" ></asp:ListItem> 
                                </asp:RadioButtonList> 
                            </CommandItemTemplate> 
                            <Columns> 
                               ... 
                          
                              </Columns> 
                          </telerik:GridTableView> 
                        </DetailTables> 
                        
                      </telerik:GridTableView> 
                    </DetailTables> 
                 
            </MasterTableView> 
          
        </telerik:RadGrid> 

CS:
 
 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        RadioButtonList radbtn = (RadioButtonList)sender; 
        GridCommandItem cmdItem = (GridCommandItem)radbtn.NamingContainer; 
        GridTableView ChildGrid = (GridTableView)cmdItem.OwnerTableView; 
        if (radbtn.SelectedValue == "All"
        { 
            ChildGrid.AllowPaging = false
        } 
        else 
        { 
            int CurrentPageSize =Convert.ToInt16(radbtn.SelectedValue); 
            ChildGrid.AllowPaging = true
            ChildGrid.PageSize = CurrentPageSize; 
        } 
        ChildGrid.Rebind(); 
    } 

Hope this helps..
Princy

Tags
Grid
Asked by
Erik Hinds
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or