Instead of using the Datagrid name as a string in the JavaScript widget configuration, follow these steps:
Remove the Datagrid name field from the Export To Excel JavaScript action configuration.
Make sure you pass the selected items from the DataGrid as a parameter:
You’re already doing this in actionButton4 by setting the argument to Selection of dataGrid2_1.
Modify the Export To Excel JavaScript action to use the EntityList parameter directly, instead of trying to access the DataGrid by name.
The widget can automatically handle the export using the list if it’s passed correctly.
This avoids any issues with undefined or DOM lookup failures.
I hope this can be helpful.