Hi Paul,
Your scenario is similar to Orders -> OrderDetails from our Sample database. Maybe you can invoke createXXX on DataGrid Add (instead Add dialog open), get the Id of the created record and use it for Edit dialog:
Edit Order in this case will have OrderDetails grid:
Source code of the app can be found here:
When you click Cancel the record will be deleted.