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

hierarchy detail table

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
appdev
Top achievements
Rank 1
appdev asked on 27 Oct 2008, 01:24 PM
i want to create a dynamic report  that has the same Hierarchy with DetailTableDataBind event format but with different data. using store procedure to get the datas, how do i specify the mastertableview,detailview and column, and how do i do all of this in the server side. Plus how do i export all data on this to excel.

so if i have table call student
name     address      shoes         shirt     zip  city state size

i want name to be master,address to be detail, shoes to be detail again

so if a user select a report call student it will get the above info and generate a Hierarchy with DetailTableDataBind event with the above info.

if a user select grade report, it will select info from grade table
level     class      test      number
and level will be master, class will be detailtable.

and so on. could i do all this on server side and i want to be able to say e.detailtableview.datasource = "exec storedprocedure ......"

thank you very much for your help . i really appreciate it.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2008, 07:39 AM
Hello,

A suggestion is to use the NestedViewTemplate with a grid in it and then change the datasource of the grid based on the parent item condition. Check out the code below for implementing this scenario.
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" OnPreRender="RadGrid1_PreRender"
   <MasterTableView> 
   <NestedViewTemplate> 
     <telerik:RadGrid runat="server" ID="RadGrid3" AutoGenerateColumns="true">        
     </telerik:RadGrid> 
   </NestedViewTemplate>    
      ..... 

cs:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.Expanded) 
            { 
                foreach (GridNestedViewItem nestedViewItem in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)) 
                { 
                    RadGrid Grid2 = (RadGrid)nestedViewItem.FindControl("RadGrid3"); 
 
                    if (item["Report"].Text == "student") 
                    { 
                        Grid2.DataSource = "DataSource1";// Bind the grid to the datasource here 
                    } 
 
                    if (item["Report"].Text == "grade") 
                    { 
                        Grid2.DataSource = "DataSource2";// Bind the grid to the datasource here 
                    } 
                     
                } 
            } 
        }     
    } 

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