I have an ultrawebgrid on my page with parent rows of employees and child rows of hours worked per month on different projects.
On the child rows I have a footer that sums all the hours worked during the months of the year (say Jan for example) for all projects. Using the following code I am able to loop thru the child rows for a column when one of the project hour columns have been updated and add up all the hours for projects for the updated column for the month.
Now I need to take the totalCellAmount and update the footer cell for the updated column. I have found a setFooterText and an example using it but I can't figure out how to make it work in my code for my child rows footer.
Here is my code so far caculating the new footer amount but I can't figure out how to set the footer amount. Any help would be appreicated.
function UpdateFooter( gridName, cellId ){ var column = igtbl_getColumnById(cellId); var cell = igtbl_getCellById(cellId); var row = cell.Row; var parentRow = row.ParentRow; var totalCellAmount = 0; for(var i=0; i<=row.ParentRow.VisChildRowsCount-1; i++) { var cellAmount = parentRow.getChildRow(i).getCellFromKey(column.Key).getValue(); totalCellAmount = parseFloat(totalCellAmount) + parseFloat(cellAmount); alert("Total %: " + totalCellAmount); }}
Found that I didn't need to loop thru all rows so I have removed that loop code and now I am just looping thru the childrows where the update occurred.
function UpdateFooter( gridName, cellId ){ var grid = igtbl_getGridById(gridName); var column = igtbl_getColumnById(cellId); var cell = igtbl_getCellById(cellId); var footercell = igtbl_getElementById(cellId); var row = cell.Row; var parentRow = row.ParentRow; var totalCellAmount = 0; var columnIndex = column.getRealIndex(row); var bandIndex = row.Band.Index; //make sure we have a child record if(bandIndex=="1") { //loop thru the child rows and add up the totals for(var i=0; i<=row.ParentRow.VisChildRowsCount-1; i++) { //get amount from row var cellAmount = parentRow.getChildRow(i).getCellFromKey(column.Key).getValue(); //add amount to cell total variable totalCellAmount = parseFloat(totalCellAmount) + parseFloat(cellAmount); } //get the footer row var footer=footercell.parentNode.parentNode.nextSibling.childNodes[0].childNodes[columnIndex]; //update the footer text with the total amount footer.innerText=totalCellAmount; }}