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

Display Datatable column in NestedViewTemplate

1 Answer 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
derek
Top achievements
Rank 2
derek asked on 07 May 2009, 08:26 PM
I'm using the Telerik:RadGrid to display a list of courses. The course information is all in a DataTable bound to the grid.

Most of the data is small and works well as a list, except for the course description which is a large paragraph.  I would like the description to be display for each row in the nestedviewtemplate so that it shows up as a full row when the master row is clicked.

I've seen the hierachy template example for the grid control, but that is based on multiple DataTables. All of the information I have is in a single table.

Is there a simple way with the grid to access the DataField for the description from inside the NestedViewTemplate?
DataTable CourseTable = new DataTable("CourseTable"); 
            CourseTable.Columns.Add(new DataColumn("Course", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Section", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Title", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Session", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Professor(s)", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Units", Type.GetType("System.Int32"))); 
            CourseTable.Columns.Add(new DataColumn("Schedule", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Cohort", Type.GetType("System.String"))); 
            CourseTable.Columns.Add(new DataColumn("Description", Type.GetType("System.String"))); 


<telerik:RadGrid ID="GridCore" runat="server" Skin="WebBlue" AutoGenerateColumns="false"
            <MasterTableView> 
                <NestedViewTemplate> 
                    <!-- Need to Add the Description column in here" --> 
                </NestedViewTemplate> 
                <Columns> 
                    <telerik:GridBoundColumn HeaderText = "Course" DataField = "Course"/> 
                    <telerik:GridBoundColumn HeaderText = "Section" DataField = "Section"/> 
                    <telerik:GridBoundColumn HeaderText = "Title" DataField = "Title"/> 
                    <telerik:GridBoundColumn HeaderText = "Professor(s)" DataField = "Professor(s)"/> 
                    <telerik:GridBoundColumn HeaderText = "Units" DataField = "Units"/> 
                    <telerik:GridBoundColumn HeaderText = "Schedule" DataField = "Schedule"/> 
                    <telerik:GridBoundColumn HeaderText = "Cohort" DataField = "Cohort"/> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 

1 Answer, 1 is accepted

Sort by
0
derek
Top achievements
Rank 2
answered on 07 May 2009, 09:18 PM
I was actually able to solve my own issue, here is is in case anyone is interested. This allows you to display an additional column from a DataTable. I just had to make sure that both grids had the unique identifier from the DataTable, then I hid them as they're not ment for display.
<telerik:RadGrid ID="GridCore" runat="server" Skin="WebBlue" AutoGenerateColumns="false"
            <MasterTableView DataKeyNames="CRN"
                <DetailTables> 
                    <telerik:GridTableView DataKeyNames="CRN" ShowHeader="false"
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="CRN" MasterKeyField="CRN" /> 
                        </ParentTableRelation> 
                        <Columns> 
                            <telerik:GridBoundColumn HeaderText = "CRN" DataField = "CRN" Visible="false"/> 
                            <telerik:GridBoundColumn HeaderText = "Description" DataField = "Description"/> 
                        </Columns> 
                    </telerik:GridTableView> 
                </DetailTables> 
                <Columns> 
                    <telerik:GridBoundColumn HeaderText = "CRN" DataField = "CRN" Visible="false"/> 
                    <telerik:GridBoundColumn HeaderText = "Course" DataField = "Course"/> 
                    <telerik:GridBoundColumn HeaderText = "Section" DataField = "Section"/> 
                    <telerik:GridBoundColumn HeaderText = "Title" DataField = "Title"/> 
                    <telerik:GridBoundColumn HeaderText = "Professor(s)" DataField = "Professor(s)"/> 
                    <telerik:GridBoundColumn HeaderText = "Units" DataField = "Units"/> 
                    <telerik:GridBoundColumn HeaderText = "Schedule" DataField = "Schedule"/> 
                    <telerik:GridBoundColumn HeaderText = "Cohort" DataField = "Cohort"/> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
able into a detail sections.
Tags
Grid
Asked by
derek
Top achievements
Rank 2
Answers by
derek
Top achievements
Rank 2
Share this question
or