First, add a non persistent helper entity to the page. Create an association from the helper to the entity that is displayed in the first dg2.
Create an on click event at the first datagrid. within this event microflow, set the association mentioned above.
In the second datagrid, add the xpath constraint so that the value matches the selected value (associated value from the helper entity)
You can hide the second datagrid using a visibility rule that checks the association set between the helper entity and the object selected in the first datagrid. The association should not be empty for the second datagrid to be displayed.
Goodluck!