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

[Solved] RadGrids inside RadGrid export to Word issue: Header with "Item" string

4 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mary
Top achievements
Rank 1
Mary asked on 23 Jul 2013, 11:57 AM
Hi!
I wanted to export several radgrids to a Word document, so I found out an example that suggested to wrap the grids into a global grid.
That's what I've done with the structure below: 
The problem I'm facing is in my Word document there is a string with the literal "Item" below the caption "This is the caption" and before my inner radgrid. 
I'm never setting this string, so I guess it's a default value I don't even know how to change. I don't know how to hide it in the Word document, although I managed to hide it with css in the web layer. 
Any suggestion would be appreciated, 

Thanks in advance,

Mary.

 <telerik:RadGrid ID="RadGridWrapper" runat="server" BorderStyle="None" ShowHeader="false" ShowFooter="false"    
        OnGridExporting="OnGridExporting"> 
        <MasterTableView AutoGenerateColumns="true" ShowHeadersWhenNoRecords="true" 
        NoMasterRecordsText="<%$ Resources:GlobalResources, NoResults%>"
        ShowHeader="true" ShowFooter="false" Caption="This is the caption"  >
            <ItemTemplate>
                <telerik:RadGrid ID="RadGrid1" runat="server"
                 GridLines="Both" Skin="Windows7"
                    HorizontalAlign="Center" AutoGenerateColumns="false"
                     OnNeedDataSource="RadGrid_NeedDataSource1" >
<MasterTableView> ... </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadGrid ID="RadGrid2" runat="server" GridLines="Both" 
                OnNeedDataSource="RadGrid_NeedDataSource2"
                    Skin="Windows7" HorizontalAlign="Center" AutoGenerateColumns="false">
<MasterTableView> ... </MasterTableView>
    </telerik:RadGrid>
  </ItemTemplate>           
        </MasterTableView>
    </telerik:RadGrid>


4 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 26 Jul 2013, 06:47 AM
Hi Mary,

You could hook OnGridExporting event handler and modify the export output as shown in the following code snippet:
protected void RadGridWrapper_GridExporting(object sender, GridExportingArgs e)
{
    e.ExportOutput = e.ExportOutput.Replace("<th scope=\"col\">Item</th>", "");
}


Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Mary
Top achievements
Rank 1
answered on 26 Jul 2013, 07:29 AM
Thank you, it worked perfectly :)
0
Mary
Top achievements
Rank 1
answered on 26 Jul 2013, 08:35 AM
Can I also ask you for a couple of issues I'm facing with this Word document?

First of all, I find this document very plain. It's opened by default in a "Web Layout" view. Is there any way to force the document to be opened in a print layout?

Second, my inner tables are quite wide, I would also like to set orientation as landscape if possible, but how?

Third, if I set both first and second points manually using Word, I find that paging is carried out, and main grid caption is repeated on top of every page, but it would be nicer if the caption of the inner grid which is actually split by the page could be repeated instead. Maybe I'm asking for too much?

And finally, header and footer of the Word document with page numbers would also be a desirable feature, but once again, I don't know how.

I hope you can help me with my questions, thank you in advance,

Mary.
0
Kostadin
Telerik team
answered on 31 Jul 2013, 06:20 AM
Hello Mary,

I am afraid that the Word export is the format which could not be modified. From all of your requirements only the layout could be changed by hooking HTMLExporting event. Please check out the following code snippet.
protected void RadGrid1_HTMLExporting(object sender, GridHTMLExportingEventArgs e)
{
    e.XmlOptions = @"<xml>
                        <w:WordDocument>
                            <w:View>Print</w:View>
                        </w:WordDocument>
                     </xml>";
}

You could check out the following help article which is elaborates more on the Html-Based export format and the following one related to Word Export. For more advanced feature I would recommend you to use export to Excel.


Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Mary
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Mary
Top achievements
Rank 1
Share this question
or