MandyProgza
asked on
looping with javascript
Hi
I need help with creating a loop on an Infragistics webgrid with javascript. The grid has 3 columns, I add values in column 1 and 2 and put the result in column 3, for each row.
Then I add values on the same column, row 1 and row 2 and put the result on row 0. I want it to be automatically done as values change on different rows/columns.
I used the attached and was only able to get part of the expected outcome.
I attached the code that I am currently using and the desired outcome on the excel spreadsheet.
Assistance will be greatly appreciated.
Regards
MandyProg
CellUpdateHandler.txt
example-of-grid.xlsx
I need help with creating a loop on an Infragistics webgrid with javascript. The grid has 3 columns, I add values in column 1 and 2 and put the result in column 3, for each row.
Then I add values on the same column, row 1 and row 2 and put the result on row 0. I want it to be automatically done as values change on different rows/columns.
I used the attached and was only able to get part of the expected outcome.
I attached the code that I am currently using and the desired outcome on the excel spreadsheet.
Assistance will be greatly appreciated.
Regards
MandyProg
CellUpdateHandler.txt
example-of-grid.xlsx
Second, you need to use the same variable names.
This:
Further, I'd change the code as follows:
This:
var total = 0;
should be this:
var Total = 0;
Further, I'd change the code as follows:
function Grid1AfterCellUpdateHandler(gridName, cellId) {
var activeRow = igtbl_getActiveRow(gridName);
// Calculate Total for current year
// Get values from the grid and populate the variables
var Col1 = activeRow.getCell(9).getValue() || 0;
var Col2 = activeRow.getCell(10).getValue() || 0;
activeRow.getCell(11).setValue(parseFloat(Col1) + parseFloat(Col2));
// Calculate total for previous year
var Col10 = activeRow.getCell(13).getValue() || 0;
var Col20 = activeRow.getCell(14).getValue() || 0;
activeRow.getCell(15).setValue(parseFloat(Col10) + parseFloat(Col20));
}
ASKER
Hi
Thanks for the recommendations. The column on the last row only gets the correct total if I tab into the column, else it displays the old figure. Anyway to have it updated? if the cell on the column gets updated regardless of which column/cell has the focus?
e.g. I change row2 on column 1, then row 0 of column 1 gets the new column total, third column on row 2 also gets updated but the grand total for the last column on row 0 doesn't get updated.
MandyProg.
Thanks for the recommendations. The column on the last row only gets the correct total if I tab into the column, else it displays the old figure. Anyway to have it updated? if the cell on the column gets updated regardless of which column/cell has the focus?
e.g. I change row2 on column 1, then row 0 of column 1 gets the new column total, third column on row 2 also gets updated but the grand total for the last column on row 0 doesn't get updated.
MandyProg.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot!
No worries - glad to help.
Open in new window
should be this:Open in new window