Hi all,
I found this great blog by infragistics on including igGrid with Durandal 2 support.
http://ko.infragistics.com/community/blogs/pivanov/archive/2014/09/16/adding-iggrid-in-durandal-2.aspx
How would I do an excel export with Durandal 2? Is there an example for this?
All the examples I find for excel are using something like the following:
<script id = "exportGrid"> function exportGrid() { $.ig.GridExcelExporter.export($("#grid"), { fileName: "igGrid" }); }; </script>
This however does not seem to work using Durandal 2.
Any reference materials, sample project, or examples on how this works? I looked over the iggrid documentation without much success to find other approaches.
Thanks,
Hi,
Thank you for posting in the Infragistics community ! I am currently working onto your issue and will update you with my findings.
Basically the igGridExcelExporter needs its resources to be loaded in order to work and anything else. However I have been trying to export the grid in a Durandal 2 app and did not succeed so far. I have been working with the sample shared at http://ko.infragistics.com/community/blogs/pivanov/archive/2014/09/16/adding-iggrid-in-durandal-2.aspx
What I did is:
1) added the required js resources inside the lib/infragistics folder. Required resources are the following: (you can download them from the below links and place them in the lib/infragistics folder):
<script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/modules/infragistics.documents.core.js"></script><script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/modules/infragistics.excel.js"></script><script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/modules/infragistics.gridexcelexporter.js"></script> <script src="http://www.igniteui.com/js/external/FileSaver.js"></script><script src="http://www.igniteui.com/js/external/Blob.js"></script>
2) Placing the resources inside the define wrapper:
define(['knockout', 'jquery', 'jquery.ui', 'knockout.mapping', 'infragistics.core', 'infragistics.lob', 'infragistics.ds.knockout', 'infragistics.grid.knockout', 'infragistics.excel', 'infragistics.documents.core', 'infragistics.gridexcelexporter', 'FileSaver', 'Blob' ],
3) and also added thourgh the RequireJS:
shim: {.... 'infragistics.documents.core': { deps: ['jquery', 'jquery.ui', 'infragistics.core', 'infragistics.lob'] }, 'infragistics.gridexcelexporter': { deps: ['jquery', 'jquery.ui', 'infragistics.excel', 'infragistics.documents.core'] }, 'infragistics.excel': { deps: ['infragistics.lob'] }, }
However it seems that $.ig.excel is not available in the app for some reason and I am taking more time for investigating. However it will be helpful if you update me at that time with information on did you manage to load the resources or you are facing another issue with the exporting process. Looking forward to hearing from you.
I ran into the exact same issue and am unable to get $.ig.excel to be recognized. It is also not clear for me how to use the examples to export as the script seems to get deleted from the view, and it doesnt appear that I can access the #grid in the view from the view model. I thought this would be simple :)
Hi Miles,
How do you try to access the grid from the viewmodel ? It is possible that Durandal will look for it in the viewmodels path and does not find it. If this is the case a possible solution is to change what is returned by the convertModuleIdToViewID. However you may want to provide me with more details before looking further into this.
I have not tried, as I do not see a way to access a view object '#grid' from the view model. I have not been able to get any kind of export working.
Do you happen to experience the same if you reference the necessary resources in the index.html ?:
<!-- Ignite UI Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/infragistics.dv.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2015.1/latest/js/modules/infragistics.excel.js"></script>
<!-- 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>
When you reference those and run $.ig.GridExcelExporter.export($("#grid")); what's the result ? Looking forward to hearing from you.
Hello,
I'm just following up to see if you need any further assistance with this issue. If so please let me know.
This has been determined to be a wrong behavior, so I have created a support case for you with id of CAS-158258-R7X4Q8 that is linked to the Development Issue with ID of 202678. You will receive responses and notifications in the corresponding case.
Please let me know if I may be of any further assistance to you.
Hi. you are right. Anyway my suggestion was just to test if this would work on your side. I am continuing my investigation to figure this out - as I said issue is that $.ig.excel for some reason is not available, even though infragistics.excel.js is properly loaded as a resource. I will keep you posted with my findings.
If I put only those scripts in index.html, $ / jquery among others will come up as undefined because they are not defined in index.html. You would end up having to define all dependencies in index.html, knockout, mapping, etc. I am not sure that approach would work either.