549
Views
8
Comments
Solved
[OutSystems Data Grid] DataGridReact Forge - Export to Excel via button displayed instead of Context Menu
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
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!





2020-08-05 09-00-16
Gabriel Lundgren
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
UserImage.jpg
Naku Sitsu

Can you tell me why it is written like this in JS? I don't quite understand. Thank you very much!

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

2020-08-05 09-00-16
Gabriel Lundgren

Hey Michelle,


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


Gabriel Lundgren

UserImage.jpg
Michelle Ko

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".

2020-08-05 09-00-16
Gabriel Lundgren

Hey Michelle,


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

UserImage.jpg
Michelle Ko

Gabriel,

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

Thanks!

SampleGridExportToExcel.oml
UserImage.jpg
Michelle Ko

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!


2020-08-05 09-00-16
Gabriel Lundgren
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
UserImage.jpg
Naku Sitsu

Can you tell me why it is written like this in JS? I don't quite understand. Thank you very much!

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

UserImage.jpg
Michelle Ko

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.