Following is the JavaScript sample you may have to tweak the code to fit your situation....
// Invoke the Instance Manager to remove the current instance of the detail subform.
_<SubformName/RowSOMName>.removeInstance(index of the object to remove)
//_Section2Detail.removeInstance(this.parent.index); //in my case I have a delete button next to each row when clicked that will pass the index of the parent(row index as it is part of that row).
// Invoke the recalculate method to update the form calculations.
xfa.form.recalculate(1);