Hi Team,
I need to export grid as well as hierarchical grid to excel/pdf.
I am using the below code:
function exportToExcel() { $.ig.GridExcelExporter.export($("#gridCategory"), {
dataExportMode: $("#dataExportMode").val() });
The export functionality is not working and is giving the error:
I am using the version: 13.2.20132.1010 (as mentioned in infragistics.core.js file)
Hi Agraj,
The igGridExcelExporter has been introduced with 15.1 volume of IgniteUI initially supporting igGrid export. With 15.2 the support of igTreeGrid and igHierarchicalGrid was introduced. In order to use it you need to upgrade your application to 15.1 or later. If you stay with the 13.2 volume you can export the igGrid using the ASP.NET MVC Excel library as shown in http://www.igniteui.com/infragistics-excel/overview
If you are going to upgrade your application I suggest that you start with the samples here:
https://www.igniteui.com/grid/export-basic-grid
and with the help topic here:
https://www.igniteui.com/help/iggridexcelexporter-overview
Please let me know if you have further questions on the matter.
Thanks Hristo for your response.
I switched to 15.2.20152.1027 version, now when I run the application, the data inside the is not being displayed (only header is displayed). Not sure if I am doing something wrong. In the Chrome console window, it says: "Cannot read property 'key' of undefined - infragistics.lob.js.
I replaced the MVC dll and the below Javascript files:
-infragistics.core.js
-infragistics.lob.js
-infragistics.loader.js
-infragistics.documents-core.js
-infragistics.excel.js
-infragistics.gridexcelexporter.js
Please assist. Thank you.
-Regards,
Agraj
Hi Hristo,
Any updates on the issue I am facing?
Thank you for the sample shared. Actually I configured it to bind to my local sql database and grid loads fine without any errors, also exporting works fine without touching the code.
I suggest you reaasure that column keys match the datafield names as they come from the sql. If you do not manage to figure this out we can arrange a live web session. Looking forward to hearing from you.
Thank you for your response.
When I just replace the infragistics.lob.js and infragistics.core.js files to the old version, data is displayed in the Grid without any code change. But again when I switch these files to newer version, there is no data.
I tried clearing the browser history, cleaning the solution. Attaching the browser screenshot with the console error in the below pane.
Request you to please help me solve this long pending issue at the earliest.
Hi,
I just checked, there is some issue in the infragistics.lob.js file. I have only the infragistics.lob.js file of the old version, rest all (dll and other js of the new version, the data is displayed).
But again, with this, for export I get the below error:
Uncaught TypeError: Object [object Object] has no method 'headersTable'
This is really taking a long time and I do not have any clue how and where to proceed.
This is strange since in the attached sample all IgniteUI js resources are of the same version. Anyway, it is possible you have been referring a diff version elsewhere in the project.
If you managed to get the grid rendered and then you have this error on exporting, please make a snapshot of the error again and provide the igGrid initialization code generated on the client - this will be enough for me to investigate and suggest solution/fix for the issue. Looking forward to hearing from you.
I have investigated this further, please see below my comments:
1) I export the grid successfully, but without doing any postback, if I try to export it again, I export starts, but I get the error message: Export Failed, No file.
- I am not able to reproduce this behavior, please provide grid initializaton code in Razor or jquery or upload a modified sample reproducing the issue that I will be able to modify.
2) When I try to export Hierarchical grid, I get the error message: Uncaught TypeError: Cannot read property 'length' of undefined
I reproduced the issue and investigated it. The issue is caused by the fact that there is Paging enabled and when the exporter tries to check if a row from the second page is expanded, then this row is not available, since it is on another page. This is considered as a wrong behavior and I have logged it in our internal system for reviewing and fixing. I have also created a support case for you linked to that issue so that you receive automatic notifications on the status of the issue. the support case number is CAS-167011-J1V851. A workaround is suggested in 2.1 below
If we get the paging removed or pageSize increased we will overcome this issue, but then another one will occur as a result from exporting the sorting feature. This is considered as a wrong behavior and I have logged it in our internal system for reviewing and fixing. I have also created a support case for you linked to that issue so that you receive automatic notifications on the status of the issue. the support case number is CAS-167012-F9X1N5. A workaround is suggested in 2.2 below
Furthermore, please pay attention that:
2.1) The workaround is to turn off paging for the given grid
2.2) Because of exporting the Sorting feature will result in an error, as a workaround I suggest that you don't apply Sorting until this issue is fixed.
2.3) the igGridExporter does not support MultiColumnHeaders (supported features are listed at http://www.igniteui.com/help/api/2015.2/ig.gridexcelexporter) so having such a column disrupts the normal workflow and exported worksheet consistency. This column should be skipped in exporting by using the columnsToSkip property. Since this property works with column keys you need to supply a columnKey for the MultiColumnHeader, as you have supplied for the other columns.
2.4) Because of a MultiColumnHeader rendered in the igGrid, the DOM structure is modified and igGridExporter failes to get the proper styling and style the excel worksheet appropriately. This is considered as a wrong behavior and I have logged it in our internal system for reviewing and fixing. I have also created a support case for you linked to that issue so that you receive automatic notifications on the status of the issue. The support case number is CAS-167013-W6R3L1. In order to work around this until the issue is fixed, I suggest to apply some of the predefined table styles.
Until all those issues are fixed ( you will receive automatic notifications in the corresponding cases) I suggest a workaround that involves exporting a grid without the multicolumnheader and without paging. To achieve this my suggestion is to create a new grid, export it and destroy the newly created grid. I have modified your sample to demonstrate this approach - download it from this post and review the workflow. Please let me know if this approach doesn't work for you - in such case I will provide another workaround solution.
I am using 15.2.20152.1027 version.
You can use the same application which I uploaded earlier. Just disabled that Responsive mode feature.
Also, attaching the error screenshot for your reference.
I have another application in which resources specific to my project are present, there I am able to download the excel once (document (14).xlsx - in the screenshot), when I try again, I get the error - Failed, No File.
When I try to perform export in the application uploaded earlier in the mail, I get the errors like - no method 'u', Invalid Enum Argument - format value: 2, etc (screenshot attached).
I want to export grid and hierarchical grid with features.
Also, regarding providing context information, if I would have known this Grid responsive setting might cause the error, I would have disabled that earlier itself. Is this setting listed anywhere in the documentation?
I am glad this helped you resolve your issue. According your latest questions - I cannot assume what is the cause since you have not provided enough context information. Starting from 15.2 the GridExcelExporter supports exporting an igHierachicalGrid, so please let me know what version you are using eventually. However most helpful will be if you provide a sample that reproduces the issue which will enable me to instantly investigate it and suggest accordingly. Same is valid for the other error too - Failed, No File.
Looking forward to hearing from you.
Thank you for your helpful reply. Finally, I am able to bind the data to the grid and display it in browser.
One suggestion, I am not sure whether this is documented anywhere, but this issue is likely to be missed. You guys should also focus on increasing the samples to cover such scenarios.
I am able to export the grid as well now, but still there are few issues:
$.ig.GridExcelExporter.exportGrid($("#grid11"));
When using columnHiding in Responsive Web Design Mode it is recommended to set hidden columns in the Responsive feature columnSettings object:
gridModel.Features.Add(new GridResponsive() { EnableVerticalRendering = true, ColumnSettings = new List() { new ResponsiveColumnSetting() { ColumnKey = "ResponsibleUnitIdResponsibleUnitId", Classes="hidden-tablet hidden-phone hidden-desktop" } } });
This means you also need to remove the hidden: true property from line 118:
gridModel.Columns.Add(new GridColumn() { HeaderText = "Responsible Unit Id", Key = "ResponsibleUnitId", Hidden=true, DataType = "string", Width = "200px" });
Please let me know if you have further questions on the matter, I will be glad to help.
st Regards,Hristo AnastasovAssociate Software DeveloperInfragistics, Inc.