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

[Solved] Need to display fully expanded detail gridtableview at same level as mastertableview (templates?)

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 31 May 2009, 07:51 PM
Hi,

I'm currently displaying some xml data (using xmldatasource bound to a DataList).  I want to replace this DataList with the Grid - and display it in the same way (see the example below) 

The DataList has a HeaderTemplate (circled in purple in the example), an ItemTemplate (circled in blue) and an AlternatingItemTemplate (green). 

I created one grid version using MasterTableView, DetailTables, two GridTableViews and assoicated Columns sections and was able to display data as per the grid version example below.  The upper-level team attributes data is shown in MasterTableView and the RaceClasses and TeamMember information is shown at the same level in the two detail GridTableViews.

Moving back to the DataList example, I have circled in red and marked M1, D1 and D2 where the corresponding data would/should show up if I can make this work using the Grid as desired.

I tried using the ItemTemplate in the MasterTableView but was not able to gain access to any of the data provided by the XmlDataSource.

Click here for DataList example
Click here for the grid version
Click Here to See XML Data

I'm appreciative of your time, analysis and any thoughts you might have on the question:

Thanks,
David

2 Answers, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 01 Jun 2009, 01:05 PM
Hello David,

Indeed, you can use GridTemplateColumn to achieve your goal. In the MasterTableView level, you can have some GridBoundColumns for the master table record. Then in a GridTemplateColumn, you can add another RadGrid in its ItemTemplate and bound it to the corresponding data.

Check it out and let me know if you need further directions.

Kind regards,
Iana
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.
0
David
Top achievements
Rank 1
answered on 02 Jun 2009, 05:28 PM
Hi, thanks for the help.  I'm in the process of implementing your suggestion and am wondering if there is a better way to find the DataKeyValue from the parent grid than the way I came up with below:

    protected void ClassGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        if (!e.IsFromDetailTable)
        {           
            // Is there a better way to get at the desired index?
            string entryId = ((GridDataItem)((GridTableCell)((RadGrid) source).Parent).Parent).GetDataKeyValue("entryid").ToString();

            XmlDataSource2.XPath = String.Format("Entries/Entry[@entryid='{0}']/RaceClasses/RaceClass", entryId);
            ((RadGrid) source).DataSource = XmlDataSource2;
        }
    }

Thanks!
David
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
David
Top achievements
Rank 1
Share this question
or