In Dynamics 365, you can add or remove onload events from a sub-grid by referencing functions by name. The two examples below show how this is done.
Xrm.Page.getControl("mag_mygrid").addOnLoad(myMethod);
Xrm.Page.getControl("mag_mygrid").removeOnLoad(myMethod)
Because the addOnLoad and removeOnLoad functions only accept the event function name as a parameter, you cannot pass additional parameters to your function using this approach.
A workaround is to use anonymous functions instead.
Xrm.Page.getControl("mag_mygrid").addOnLoad(function(){ myMethod (parameter} });
The downside to this is that you cannot remove the anonymous function above as it does not have a function name.