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,
I am not able to assume what the issue is this way. It will be helpful if you provide the code of your view page so that I can assure you have properly loaded all the resources. Please noe that you also need the FileSaver and Blob libraries in order for the exported sheet to be saved locally:
<!-- External files for exporting --> <script src="http://www.igniteui.com/js/external/FileSaver.js"></script> <script src="http://www.igniteui.com/js/external/Blob.js"></script>
Also, please specify if the error you receive is displayed while loading or on certain action (like exporting). Looking forward to hearing from you.
Hi Hristo,
I receive this error while loading the View.
Also, I have specified bundles in BundleConfig.cs file as mentioned below:
public static void RegisterBundles(BundleCollection bundles) { // styles bundles var core = new StyleBundle("~/assets/bundles/css") .Include("~/Assets/css/main.css") .Include("~/Assets/css/site.css") .Include("~/Assets/css/spinner.css") .Include("~/Assets/css/infragistics.theme.custom.css") .Include("~/Assets/css/infragistics.css") .Include("~/Assets/css/infragistics.structure.css") .Include("~/Assets/css/fonts.css")/*Fonts*/ .Include("~/Assets/css/custom.css");
core.Transforms.Add(new CssMinify()); bundles.Add(core);
// java scripts bundles var coreJs = new ScriptBundle("~/bundles/js") .Include("~/Assets/js/jquery/jquery-2.0.3.js") .Include("~/Assets/js/jquery/jquery-ui-1.10.3.js") .Include("~/Assets/js/plugins/jquery.cookie.js") .Include("~/Assets/js/modernizr-2.6.2.js") .Include("~/Assets/js/main.js") .Include("~/Assets/js/custom.js") .Include("~/Assets/js/plugins.js") .Include("~/Assets/js/plugins/transition.js") .Include("~/Assets/js/plugins/tab.js") .Include("~/Assets/js/infragistics.core.js") .Include("~/Assets/js/infragistics.lob.js") .Include("~/Assets/js/infragistics.loader.js") .Include("~/Assets/js/filesaver.js") .Include("~/Assets/js/blob.js") .Include("~/Assets/js/jquery/jquery.ui-contextmenu.js") .Include("~/Assets/js/modules/infragistics.documents.core.js") .Include("~/Assets/js/modules/infragistics.excel.js") .Include("~/Assets/js/modules/infragistics.gridexcelexporter.js") ; coreJs.Transforms.Add(new JsMinify()); bundles.Add(coreJs); }
I am building the grid in the controller using GridModel and in the view I just have this code:
@model Infragistics.Web.Mvc.GridModel
@Html.Infragistics().Grid(Model)
Please let me know if you need any further details.
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.