I am getting a subgrid's recordcount inside of its onload function like so:
Xrm.Page.getControl('AllAddresses').addOnLoad(function () {
var totalCount = Xrm.Page.getControl('AllAddresses').getGrid().getTotalRecordCount();
console.log(totalCount);
});
If I add a record to the subgrid this function is triggered again, but this time totalCount is -1.
This should be the actual count of the records in the subgrid. If I reload the entire page it will log the correct count