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

DetailTable with NestedView Template inside - is it possible?

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 27 Aug 2012, 01:53 PM
Hi,

I want a RadGrid with expand/collapse functionallity.
When expanding a selected row, I want to display another RadGrid with the same functionallity, but I want to display image or some data (not a table or grid).

I read about hirarchical grids, and I need something like a grid with detailtable that has nestedview template.
Is it possible to do something like this?
Is there an implementation for expand/collapse in DetailTable?
How can I call itemcreated function for the DetailTable?

Is there any example for something like this?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 28 Aug 2012, 09:43 AM
Hello,

<telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid3_NeedDataSource"
           OnItemDataBound="RadGrid3_ItemDataBound" AllowMultiRowSelection="true" AllowAutomaticInserts="true"
           AllowFilteringByColumn="true" OnPreRender="RadGrid3_PreRender" OnDetailTableDataBind="RadGrid3_DetailTableDataBind">
           <MasterTableView CommandItemDisplay="Top">
               <Columns>
                   <telerik:GridBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID">
                   </telerik:GridBoundColumn>
                   <telerik:GridEditCommandColumn>
                   </telerik:GridEditCommandColumn>
               </Columns>
               <DetailTables>
                   <telerik:GridTableView>
                       <Columns>
                           <telerik:GridBoundColumn HeaderText="Name" DataField="Name" UniqueName="Name">
                           </telerik:GridBoundColumn>
                       </Columns>
                       <NestedViewTemplate>
                           <asp:Label ID="Label1" runat="server"></asp:Label>
                       </NestedViewTemplate>
                   </telerik:GridTableView>
               </DetailTables>
           </MasterTableView>
        
       </telerik:RadGrid>
protected void RadGrid3_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
 
        dynamic data = new[] {
            new { ID = 1, Name ="Name1"},
            new { ID = 2, Name = "Name2"},
            new { ID = 3, Name = "Name3"}
        };
        RadGrid3.DataSource = data;
 
 
    }
    protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridNestedViewItem)
        {
            GridNestedViewItem item = e.Item as GridNestedViewItem;
 
            (item.FindControl("Label1") as Label).Text = (item.ParentItem as GridDataItem)["Name"].Text  +"_NestedViewTemplate";
        }
    }
 
    protected void RadGrid3_PreRender(object sender, EventArgs e)
    {
        
    }
    protected void RadGrid3_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        dynamic data = new[] {
            new { ID = 1, Name ="Name111"},
            new { ID = 2, Name = "Name222"},
            new { ID = 3, Name = "Name333"}
        };
 
        e.DetailTableView.DataSource = data;
    }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Covertix
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or