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

Looking for Ideas on how to display multiple loosly associated DataTables

3 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 04 Dec 2008, 06:16 PM

I'm looking for any suggestions on how to display multiple DataTables from a single DataSet.  The application allows the user to create a query that extracts data from multiple source DBMS throughout the world.  Each source may have different columns but will contain roughly the same kind of data.  

Clearly one way to present the data is in a tabbed paged with one grid per page, but my client is concerned that she won't be able to see all the data at one time.   A second approach is to "pop-up" multiple windows, each with its own grid, but then the screen becomes cluttered especially if she wants to research multiple queries at the same time. 

A "hierarchical" view with the parent being a summary statement (i.e. Source, Record Count, Message) and the child is a grid displaying the DataTable results from that source.  But most (if not all) hierarchical grids assume each child is the same format.

 To add more complexity to the problem the aplication allows new sources bringing new child grid with its own columns to be dynamically created (and included in the resulting DataSet) so the display cannot reasonably use static templates.  That is the number child grids and the format of each child grid varies with each query.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Dec 2008, 11:04 AM
Hi,

Try using NestedViewTemplate and place a RadGrid in it . Set the DataSource depending on the row index to achieve the desired scenario .

ASPX:
<NestedViewTemplate> 
                       <telerik:RadGrid ID="RadGrid2"  AllowPaging="true" PageSize="5" AutoGenerateColumns="true" runat="server"
                       </telerik:RadGrid> 
                   </NestedViewTemplate> 

CS:
 protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) 
    { 
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; 
        int ParentRowIndex = dataItem.ItemIndex; 
        RadGrid nestedGrid=(RadGrid)dataItem.ChildItem.FindControl("RadGrid2"); 
        switch (ParentRowIndex) 
        { 
            case 0: 
                { 
                    conn.Open(); 
                    SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM Customers", conn); 
                    DataSet ds = new DataSet(); 
                    adp.Fill(ds); 
                    nestedGrid.DataSource = ds
                    nestedGrid.DataBind(); 
                    conn.Close(); 
                    break; 
                } 
 
            case 1: 
                { 
                    conn.Open(); 
                    SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM OrderDetails", conn); 
                    DataSet ds = new DataSet(); 
                    adp.Fill(ds); 
                    nestedGrid.DataSource = ds
                    nestedGrid.DataBind(); 
                    conn.Close(); 
                    break; 
                    
                } 
        } 
    } 


Thanks
Shinu.
0
Ceramist
Top achievements
Rank 1
answered on 04 Mar 2009, 12:57 AM
This is an interesting solution for two RadGrids, the first defining relationships between items and the second giving more detail.  However, changing the datasource of the second grid requires using an automatic format of the grid.  How would you achieve a similar result with specific formating to each datasource?  The visual power of RadGrid makes customizing the structure valuable.

One solution would be to have one RadGrid per datasource and then simply show/hide the RadGrids as necessary.  It seem that there should be a simpler mechanism.
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2009, 06:32 AM
Hi Walter,

From what you have mentioned above I guess you are trying to set the Grid structure according to the DataSource. For that you don't have to use these many Grids and show/hide accordingly. Instead you can set the AutoGenerateColumns property of the Grid which will format the Grid structure in accordance with the DataSource.

Shinu
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ceramist
Top achievements
Rank 1
Share this question
or