Interactive Grid master detail does not work this way. It allows you to change master records and does not loose the edits made to any of the details.
Can you explain why you don't want to allow the user to move on to a different master record; why force them to save?
The only reason is to allow users to trace back to the record when an input validation occurs.
At this moment when user changes Child records of Different masters and if a validation fails we get the alert "Correct Errors Before Saving"
but there is no way to identify under which master record the validation has failed.
We are aware of this issue. There is no bug number tracking it but there is this comment in the code in widget.interactiveGrid.js wrt param pModelInstanceId:
// todo currently error info doesn't have this. Needed to handle case with master detail
That is for errors coming back from the server but it is similar for client side validation.
There is no workaround for this so that the detail with the error is made visible.
There is no way to constrain selection; to not allow a change in selection state. I suppose you can listen for selection change events on the master and put the selection back if there are errors in the detail. This could be tricky because need to keep track of what the previous selection was.
I'll keep thinking about this.