Hi,
I previously asked the question how to replace html in the excel export of a grid...the solution was to implement excelQueryCellInfo on the grid to fire the function below...
function exportQueryCellInfo(args) { args.value = args.value.replace(/(<([^>]+)>)/gi, ''); }
This works fine for the content of the parent grid. However, the content of the child grid cells do not get the html removed.
As a check I have updated the function so that every cell is prepended with an X and can see in the exported excel file that only the parent grid cells have the X prepended...as you can see below. Here you can also see the html still exists in the 'Next Step' column of the child grid.
So it seems the function isn't being called for the export of the child grid..even though it is specified on the childGrid as well as the parent grid. Is this a bug or is there something else I should be doing? I'm afraid I cannot provide the full grid code as it is very long and convoluted!
I look forward to receiving your help. Thanks
Adam Toone
function exportQueryCellInfo(args) { args.value = args.value.replace(/(<([^>]+)>)/gi, ''); //here we strip out html tags from the cell content using replace() function. args.value = 'X' + args.value; }
The exported excel file:
The original grid:
|
var grid = new ej.grids.Grid({
dataSource: employeeData,
toolbar: ['ExcelExport'],
excelQueryCellInfo: exportQueryCellInfo,
. . .
childGrid: {
excelQueryCellInfo: exportQueryCellInfo,
queryString: 'EmployeeID',
. . .
},
});
grid.appendTo('#Grid');
function exportQueryCellInfo(args) {
args.value = 'X' + args.value;
}
|
Hi,
Thanks for the reply..but unfortunately this does not seem to be working. I have even used a specific function to bind excelQueryCellInfo for the child grid and this never gets hit in the debugger. Below is an example of the child grid.
We are using syncfusion version 19.3.46 @ https://cdn.syncfusion.com/ej2/dist/ej2.min.js
|
<script>
var data = new ej.data.DataManager({
url: 'http://localhost:49442/Orders',
adaptor: new ej.data.ODataV4Adaptor(),
crossDomain: true
});
var grid = new ej.grids.Grid({
dataSource: data,
height: 450,
allowSorting: true,
toolbarClick: function (args) {
if (args.item.id === "Grid_Excel Export") {
grid.excelExport({ hierarchyExportMode: 'All' });
}
},
excelQueryCellInfo: exportQueryCellInfo,
allowPaging: true,
allowEditing: true,
allowExcelExport: true,
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel', 'Excel Export'],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
columns: [
{ field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', width: 120 },
{ field: 'CustomerID', width: 140, headerText: 'Customer ID' }
],
childGrid: {
dataSource: data,
excelQueryCellInfo: exportQueryCellInfoChild,
queryString: 'OrderID',
columns: [
{ field: 'Freight', headerText: 'Freight', width: 120, format: 'C2' },
{ field: 'ShipCity', headerText: 'Ship City', width: 120 }
],
}
});
grid.appendTo('#Grid');
function exportQueryCellInfo(args) {
args.value = 'X' + args.value;
}
function exportQueryCellInfoChild(args) {
args.value = 'X' + args.value;
}
</script>
|
Hi!
I've been investigating a similar issue (maybe the same one Adam was seeing?), and it looks like the excelQueryCellInfo handler is not called on rows that are expanded. This can be reproduced in Pavithra's Stackblitz sample above (https://stackblitz.com/edit/s2hjx2?file=index.js ). Expand a row, and the exported spreadsheet's childGrid for that row will not have the prepended X in its cells.
This repros on newer builds, as well (I'm on 21.1.35).
The childGrid's properties (but not methods) get copied into grid.expandedRows. Later, DetailRow.getGridModel returns this copied object if it's available; otherwise it calls extend so the model has all the methods.
Thanks,
Ashley
Ashley,
We have modified your shared stackblitz sample and the excelQueryCellInfo event is getting triggered for the childGrid and prepended X in its cells. Please refer the below code example and sample for more information.
|
<script src="https://cdn.syncfusion.com/ej2/21.1.35/dist/ej2.min.js" type="text/javascript"></script> <link rel='nofollow' href="https://cdn.syncfusion.com/ej2/21.1.35/material.css" rel="stylesheet">
|
Sample: https://stackblitz.com/edit/s2hjx2-9lqyga?file=index.html,index.js
Thanks for your quick reply! I think my description meandered a bit - I'm talking only about childGrids that are expanded - can you double-check these steps in your sample?
Steps:
1. In the grid, click the triangle to expand at least one row (in my example below, Employee #2 (Andrew)).
2. Click export
Observe that the cells of the expanded childGrid (in my example, Andrew's rows - 10250 and 10261) don't have the prepended X.
Ashley,
We have confirmed and logged this as a bug in the component. So, we have considered ” ExcelQueryCellInfo event is not getting triggered for childGrid when the parent is expanded” as a defect and logged a report for the same. We will include the defect fix in any of our upcoming patch release.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
Feedback link : https://www.syncfusion.com/feedback/42828/excelquerycellinfo-event-is-not-getting-triggered-for-childgrid-when-the-parent-is
Has anyone found a work-around for this issue?
Ashley/Electa,
We are glad to announce that, we have included the fix for the issue “ExcelQueryCellInfo event is not getting triggered for childGrid when the parent is expanded” in our volume 1 release (21.2.4). So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue.
Release Notes: https://ej2.syncfusion.com/documentation/release-notes/21.2.4/?type=all#grid
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.