When I'm using the addOnLoad function in Dynamics CRM for my subgrid(incidents) the add button disappears. My addOnLoad event works perfectly and when I click on the delete button for a row in the subgrid the add button appears again.
Obviously there is a event that can be triggered? Since the add button appears when I'm clicking on the delete button. I don't have this problem on other subgrids with relationships to other entities than incidents.
var grid = Xrm.Page.getControl("issues");
if (grid == null) {
setTimeout(function () { AddEventToGridRefresh(); }, 5000);
return;
}
grid.addOnLoad(refreshNumberOfIncidents);
--
window.refreshNumberOfIncidents = function () {
Api.getIncidents(globals.getAccountId(), function (result) {
if (result.success) {
arrayLength = result.data.value.length;
Xrm.Page.getControl("WebResource_Interaction").getObject().contentWindow.document.getElementById("incidents").innerHTML = arrayLength;
}
});
Solved it by delaying a refresh after the addOnLoad call
setTimeout(function () { Xrm.Page.data.refresh(); }, 1000);