- Home
- Forum
- ASP.NET Core
- Action DetailTemplateInfo NOT working
Action DetailTemplateInfo NOT working
Hi there,
according to this example:
https://help.syncfusion.com/aspnet-core/grid/exporting?cs-save-lang=1&cs-lang=csharp#detailtemplate-exporting
the three methods for DetailTemplateInfo (Excel, Pdf, Word) should be executed while exporting and they should remove the unwanted chars.
BUT this is not happening! All html-tags (bold, break, etc.) are still in my output-file (excel, pdf).
Setting a breakpoint into any of these methods show, that they will not be called at all!?
So what's wrong? I copy&pasted the above example so it should work?
Kind regards,
Alexander
according to this example:
https://help.syncfusion.com/aspnet-core/grid/exporting?cs-save-lang=1&cs-lang=csharp#detailtemplate-exporting
the three methods for DetailTemplateInfo (Excel, Pdf, Word) should be executed while exporting and they should remove the unwanted chars.
BUT this is not happening! All html-tags (bold, break, etc.) are still in my output-file (excel, pdf).
Setting a breakpoint into any of these methods show, that they will not be called at all!?
So what's wrong? I copy&pasted the above example so it should work?
Kind regards,
Alexander
SIGN IN To post a reply.
1 Reply
MS
Mani Sankar Durai
Syncfusion Team
January 16, 2018 12:05 PM UTC
Hi Alexander,
Thanks for contacting Syncfusion support.
We have checked your query and we suspect that you have not able to trigger the template info event where you have removing the chars.
We have also prepared a sample that can be downloaded from the below link.
Link: http://www.syncfusion.com/downloads/support/forum/135466/ze/Exporting_with_detail_template1195291760
|
<script id="tabGridContents" type="text/x-jsrender">
...
<b class='detail'>EmployeeID</b> -
<br />
<br />
<b class='detail'>OrderID</b> -
<br />
</script>
<ej-grid id="FlatGrid" datasource="ViewBag.datasource" allow-paging="true" export-to-excel-action="/Home/ExportToExcel"
export-to-pdf-action="/Home/ExportToPdf"
export-to-word-action="/Home/ExportToWord" details-template="#tabGridContents">
...
<e-columns>
...
</e-columns>
</ej-grid>
public ActionResult ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
...
GridExcelExport exp2 = new GridExcelExport() { IncludeDetailRow = true, Theme = "flat-saffron", FileName = "Export.xlsx" };
obj.ExcelDetailTemplateInfo = templateInfo;
return exp.Export(obj, DataSource, exp2);
}
private GridProperties ConvertGridObject(string gridProperty)
{
...
}
public void templateInfo(object currentCell, object row)
{
IRange range = (IRange)currentCell;
object templates;
foreach (var data in row.GetType().GetProperties())
{
if (range.Value.Contains(data.Name)) //This will trigger when the range.value contains the field name which is in the detail grid(from the dataSource)
{
...
var charsToRemove = new string[] { "{", "}", "<b>", ":", "</b>", "<br />", "style", "=", "class", "</div>", "<p>", "</p>", "detail", "<b", ">", };
foreach (var c in charsToRemove)
{
range.Value = range.Value.ToString().Replace(c, string.Empty);
}
...
} |
From the above code example we have removed the chars if the range value contains the grid column field name (which is just for example how to export with detail template). Like-wise you can perform as per your requirement.
If you still face the issue please get back to us with the following details.
1. Share the screenshot/ video of the issue that you have faced.
2. Share the full grid code and controller page that you have used.
3. If possible please reproduce the issue in the above attached sample
The provided information will help us to analyze the issue and provide you the response as early as possible
Regards,
Manisankar Durai.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
AH Alexander Herold
- Jan 15, 2018 02:32 PM UTC
- Jan 16, 2018 12:05 PM UTC