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

custom grid header...

3 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 07 May 2013, 12:10 AM
I'm using the item template to customize the entire grid row. 

Example...

                                            <ItemTemplate >
                                                <table width="100%">
                                                    <tr>
                                                        <td style="border-style:none" ><%# Eval("StdntNm")%></td>
                                                        <td style="border-style:none" ><%# Eval("SSID")%></td>
                                                        <td style="border-style:none" ><%# Eval("AcptdDt")%></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="border-style:none" ><%# Eval("BirthFthrFrstNm")%></td>
                                                        <td style="border-style:none" ><%# Eval("BirthMthrFrstNm")%></td>
                                                    </tr>
                                                </table>

Is there a way to do the same to the grid header?  It looks like it's possible to do with a group header item...but I don't see anything similar for the normal mastertableview header.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 May 2013, 03:56 AM
Hi,

I am not sure about your requirement. I guess you want to do MultiColumn headers. Please take a look into this demo. Please elaborate your scenario if it doesn't help.

Thanks,
Princy.
0
Raymond
Top achievements
Rank 1
answered on 07 May 2013, 04:04 PM

Hi,

The problem with using the column grouping is that it requires the use of columns.  The item template appears to replace the column definitions.  Here is the header and record format I'm trying to produce:

Name                    Phone                    Address            
Position                                              Hire date
------------------------------------------------------------------------------
Fred Flintstone        555-123-4567    1234 Main St    
Senior Web Programmer                  5/1/0001

Using a table and other formatting tags (see below), I can create an item template that produces the multi-line record format as shown above.  The problem is that I don't see any way to produce the headings shown above.

It appears that using the item template turns the grid into a single column grid, with the item template being the definition for that single column.  If I could get to the column definition, I suspect I could use the same table structure to produce the desired header.  But, without a column definition...I don't see any way to access the column heading.

So the question is...in the asp below...how can I get to the column heading of the item template column in order to define it like the sample above?

<telerik:RadGrid

     ID="rgStudents"

     runat="server"

     CellSpacing="0"

     OnNeedDataSource="rgStudents_NeedDataSource"

     GridLines="Both"

     Height="50%"

     BorderStyle="None"

     OnItemCommand="rgStudents_ItemCommand"

     ClientSettings-Scrolling-AllowScroll="true"

     >

     <HeaderStyle Height="20px" />

     <ClientSettings>

         <Scrolling UseStaticHeaders="True" />

     </ClientSettings>

     <MasterTableView

         HorizontalAlign="Left"

         AutoGenerateColumns="true"

         GridLines="Both"

         ItemStyle-VerticalAlign="Middle"

         Width="100%"

    >

         <ItemTemplate >

             <table width="100%">

                 <tr>

                     <td style="border-style:none" ><%# Eval("Nm")%></td>

                     <td style="border-style:none" ><%# Eval("Phone")%></td>

                     <td style="border-style:none" ><%# Eval("Address")%></td>

                 </tr>

                 <tr>

                     <td colspan="2" style="border-style:none" ><%# Eval("Pstn")%></t

                     <td style="border-style:none" ><%# Eval("HireDt")%></td>

                 </tr>

             </table>

         </ItemTemplate>

     </MasterTableView>

 </telerik:RadGrid>

 

 

 

 

0
Raymond
Top achievements
Rank 1
answered on 07 May 2013, 04:25 PM
Never mind...I figured it out.  My problem was that I was thinking the item template defined the entire record...not just a single field

The item template, along with a header template, goes inside of a grid template column...inside the columns definition...like this.  Note:  the columns referenced in the template have to exist, but are made invisible so as not to disrupt the template.

<Columns>

     <telerik:GridTemplateColumn>

         <HeaderTemplate>

             <table width="100%">

                 <tr>

                     <td style="border-style:none" >Student Name</td>

                     <td style="border-style:none" >SSID</td>

                     <td style="border-style:none" >Accepted Date</td>

                 </tr>

                 <tr>

                     <td colspan="2" style="border-style:none" >Birth Parents</td>

                     <td style="border-style:none" ><%# Eval("BirthMthrFrstNm")%></td>

                 </tr>

             </table>

         </HeaderTemplate>

         <ItemTemplate >

             <table width="100%">

                 <tr>

                     <td style="border-style:none" ><%# Eval("StdntNm")%></td>

                     <td style="border-style:none" ><%# Eval("SSID")%></td>

                     <td style="border-style:none" ><%# Eval("AcptdDt")%></td>

                 </tr>

                 <tr>

                     <td style="border-style:none" ><%# Eval("BirthFthrFrstNm")%></td>

                     <td style="border-style:none" ><%# Eval("BirthMthrFrstNm")%></td>

                 </tr>

             </table>

         </ItemTemplate>

     </telerik:GridTemplateColumn>

     <telerik:GridBoundColumn

         UniqueName="StdntNm"

         DataField="StdntNm"

         Visible="false"

         >

     </telerik:GridBoundColumn>

     <telerik:GridBoundColumn

         UniqueName="SSID"

         DataField="SSID"

         Visible="false"

         >

     </telerik:GridBoundColumn>

     <telerik:GridBoundColumn

         UniqueName="AcptdDt"

         DataField="AcptdDt"

         Visible="false"

         >

     </telerik:GridBoundColumn>

     <telerik:GridBoundColumn

         UniqueName="BirthFthrFrstNm"

         DataField="BirthFthrFrstNm"

         Visible="false"

         >

     </telerik:GridBoundColumn>

     <telerik:GridBoundColumn

         UniqueName="BirthMthrFrstNm"

         DataField="BirthMthrFrstNm"

         Visible="false"

         >

     </telerik:GridBoundColumn>

</Columns>

Tags
Grid
Asked by
Raymond
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Raymond
Top achievements
Rank 1
Share this question
or