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

Displaying MasterTableView and GridTableView using 1 stored procedure

1 Answer 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Darrell
Top achievements
Rank 1
Darrell asked on 12 Mar 2009, 12:42 PM
We have a 4 layer hierarchy RAD Grid (1 MasterTableView and 3 GridTableView).  The MasterTableView shows the "Divisions" information, the 1st hierarchy GridTableView shows "Sites", the 2nd hierarchy GridTableView shows "Accounts", and the 3rd hierarchy shows "Fiscal Year" information.  We can show each layer by expanding/collapsing the rows.  We use advanced data binding methods (NeedDataSource for the MasterTableView and DetailTableDataBind for the 3 GridTableViews).  We use several stored procedures to get the data from the database.  This is working as designed.  Each Division can have multiple Sites.  And each Site can have multiple Accounts. The current grid resembles the following:

Division
    Sites
        Accounts
            Fiscal Year Info

We want to be able to load ALL of the Divisions and All of the corresponding Sites at the same time and expand the Divisions to show the Sites.  In other words, we want to display the MasterTableView and the 1st GridTableView using one stored procedure that gets the Divisions and all of the corresponding Sites for that Division. The Division needs to be in the MasterTableView and the Sites need to be in the 1st hierarchy GridTableView so that end-users could expand/collapse out the Divisons/Sites if needed. We want the grid to resemble the following:

Division 1
    Site 1 (for Division 1)
    Site 2 (for Division 1)
Division 2
    Site 1 (for Division 2)
    Site 2 (for Division 2)
    Site 3 (for Division 2)

Currently, we get the information back from the database using 1 stored procedure but ONLY the MasterTableView is visible and it has both the Divisions and Sites in it.  Could you please provide some assistance on how to accomplish this?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 16 Mar 2009, 03:36 PM
Hello Darrell,

To achieve your goal you need to bind the MasterTableView and the first level DetailTables. Here is an online demo which implements the suggested approach.

The second step is to set for each row, which has child controls, Expand property to "true". This action should be performed when RadGrid's OnPreRender event is raised. Here is a code snippet showing how to accomplish the suggested task:
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in ((RadGrid)sender).Items)  
        { 
            if (item.HasChildItems)  
            { 
                item.Expanded = true
            } 
        } 
    } 

Regards,
Georgi Krustev
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Darrell
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or