[Data Grid Reactive] DataGridReact Forge - Export to Excel via button displayed instead of Context Menu
Forge component by OutSystems R&D
Application Type
Reactive

Hello,

I am able to export the my grid to an excel through the Contextual Menu inside the columns ("Data Grid React" forge). However, I'd like to be able to export the grid (filters applied) from a button displayed on a page instead.  I tried calling the RunExportExcelAction js passing in the 3 parameters, but I am getting this error: Cannot read properties of undefined (reading 'export').

Can you please help?

Thank you!





Solution

Hey Michelle, 


Sorry for the late response. Could you change the RunExportExcelAction  JS to: 

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).features.export.exportToExcel($parameters.IncludeStyles, $parameters.FileName);


And pass the Grid id onto the JS block as well?


Here is the sample containing the fix.


Feel free to reach out if you have any further questions.

SampleGridExportToExcel.oml

Hey Michelle,


Could you send us a sample so we can have a better understanding of what's going on?


Gabriel Lundgren

Hi Gabriel,

I want to be able to click "Export To Excel" button to be able to export the data grid on this page.  Currently, when I click the "to Excel" in the contextual menu, it exports as expected.  I just want to be able to do the same when I click the button "Export To Excel".  Currently, I am getting below error when I click it.  The called "RunExportExcelAction" js has: $parameters.gridObject.features.export.exportToExcel($parameters.IncludeStyles, $parameters.FileName); and it does not recognized "export".

Hey Michelle,


Can you send us your OML attached so I can have a look?

Gabriel,

Below is a simple OML which I recreated for your review.

Thanks!

SampleGridExportToExcel.oml

Hi Gabriel and all,

Do you have any recommendations on how I can go about implementing this?  I tried using the JQuery to trigger the click() but that doesn't seem to work either.

Would really appreciate your help!


Solution

Hey Michelle, 


Sorry for the late response. Could you change the RunExportExcelAction  JS to: 

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).features.export.exportToExcel($parameters.IncludeStyles, $parameters.FileName);


And pass the Grid id onto the JS block as well?


Here is the sample containing the fix.


Feel free to reach out if you have any further questions.

SampleGridExportToExcel.oml

Hi Gabriel,

That worked!  The sample provided with your fix was extremely helpful.  Just wanted to let you know this forge is exactly what we needed with lots of functionality.  Awesome... Thanks again!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.