Hello, I'm trying to sum all register from a column from a Subgrid using a Javascript, I'm not really sure if Im doing correctly because the code is not working and also I added the event handler
on the new field I added to show the value of the Sum but this handler only works on onChange I can't add the event on the subgrid, if anyone can point me in the right direction , this is my code.
function totalHours(executionContext) { debugger; var formContext =executionContext.getFormContext(); if (formContext.getAttribute("Visit_Times").getValue() != null) { var count = formContext.getControl("Visit_Times").getGrid().getTotalRecordCount(); for(i = 0; i < count; i ) { var gridControl = formContext.getControl('Visit_Times').getGrid().getRows().get(i).getData().getEntity().getAttributes().get('Onsite time').getValue(); var cellValue = gridControl; cellValue = cellValue.replace( /,/,"." ); var sum = sum parseFloat(cellValue); } } formContext.getAttribute('new_TotalOnSite').setValue(sum); }
I'm not really sure in which part I'm making the mistake.
Thank you.
Kind Regards,
Jorge.