1

i have a Grid and i have 4 rows and I need to update the 4th row based on the inputs in the 1st,2nd and 3rd row values . Example :

1st when you enter 1 the total in the 4th row should be 1 when you enter 1 in 1st row and 2 in 2nd row the total shoud be 3 . Should we use java script as these rows are in a grid when we hit a pop up on the page . let me know if I am missing anything

Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100
user1567194
  • 179
  • 2
  • 3
  • 17

3 Answers3

5

This question has been already discussed in the IG forum at: http://www.infragistics.com/community/forums/t/77638.aspx

Here's what I wrote there:

You could handle the AfterCellUpdateHandler. It will fire after a cell’s value has been changed so in it you could look through the cell values and calculate the sum. After that you can change the last cell’s value. For example:

function UltraWebGrid1_AfterCellUpdateHandler(gridName, cellId){

    var cell = igtbl_getCellById(cellId);
    var totalCell = cell.Row.getCellFromKey("Total");
    var sum = 0;
    for (var i = 1; i < cell.Row.cells.length-1; i++) {
        sum += cell.Row.getCell(i).getValue();
    }
    cell.Row.getCellFromKey("Total").setValue(sum);
}

Please refer to the attached sample. In it if you change the value in any of the cells the value of the related cell from the column “Total” will be calculated based on the new values.

Let me know if you have any questions.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • 1
    just giving a link to a page is bad practice. what if this link is no longer available? – Dirty-flow Feb 12 '13 at 14:26
  • Really, I appreciate the presence of Infragistcs representative here, but I think you are not following the rules. An answer consisting of just a link is not considered a good answer also if the link points to the correct solution. Just retype here the answer and give yourself the credit due. – Steve Feb 12 '13 at 14:57
0

You can do something like

dataGridView1.Rows[0].Cells[0].Value = Convert.ToInt32(dataGridView1.Rows[1].Cells[0].Value) + Convert.ToInt32(dataGridView1.Rows[2].Cells[0].Value) ;

In the [ ], you will have to enter desired index of row or column.

0

You can use Unbound field see this example Unbound field

here you can see unbound field of subtotal,SalesTax and Total and code done at cs side in InitializeRecord event.

Gate
  • 495
  • 4
  • 11