Hi - I'm using 2009.1 Netadvantage and I'd like to Ajax enable my grid, but I need to handle the UpdateCell as soon as each cell is changed.
When I set the Browser="XML" then the UpdateCell only fires when you move off the row. Is there a way to make it fire back each time the cell is changed by the user? I need to allow them to enter a value in one cell, have that fire a server side event that then looks ups various things in the data base and fills in a number of other cells on that row in the grid.
Any suggestions much appreciated?
cheers
Jonathan
Jonathan,
Using JavaScript, you can use the client-side AfterCellUpdateHandler, get a reference to the cell that was updated, get a reference to its row, and call processUpdateRow() on that row object. You can then use the UpdateRow event to process that a change was made.
I don't have a sample available to illustrate this, and I don't immediately have a development environment available. Below is some JavaScript code which I believe will achieve the result you're after:
function ultraWebGrid1_AfterCellUpdateHandler(gridName,cellId){ var cell = igtbl_getCellById(cellId); var row = cell.Row; row.processUpdateRow();}
Hi Vince, thanks for the quick reply - it is *almost* exactly what I need....but...
The UpdateCell event is firing after the cell change (due to the processUpdateRow client side call) and I do my logic in that event to go off and update the DataTable that is the DataSource for the UltraWebGrid.
The server side code then jumps into the UpdateRow event and if I break in here I can check the data source is as I expect by doing this:
?directcast(Me.UltraWebGrid1.DataSource,DataTable).Rows(0).ItemArray
In the immediate window. This shows me the items for row 0 with all the fields I have updated....this is taking it directly from the datasource for the grid.
However, the grid itself does not show these changes!
If I add in this line
e.Row.Cells(6).Value = Now.ToString
into the UpdateRow event then I *do* see the current date/time in the 6th column of my row (which is not the field that fired the UpdateCell event - so I know it is able to update fields other than the cell I changed).
I have also tried to call
Me
.UltraWebGrid1.DataBind()
but that doesn't have any effect.
Can you think of anything i'm not doing that I should be?
Thanks again!
I just posted a question to do the almost the exact opposite of what you are requesting because I getting a refresh every time the end user changes a cell. I don't know if it is exactly what you are looking for but it might help connect the dots, hopefully:
Private
ugrdAScheduleMaint.UpdateCell
'Sets Accrual Rate value to zero when Cost Method is choosen in Accrual Method
Then
e.Cell.Row.Cells(ColumnIndex("Accrual Rate")).Value = 0
If
'sets the format for percentage columns in the UltraWebGrid
e.Cell.Column.Header.Caption
(e.Cell.Text.Replace("%", "")).ToString("N4") & "%"
(e.Cell.Text.Replace("%", "")).ToString("n4") & "%"
Select
'solves the interest formula.
= _
(
(e.Cell.Row.Cells(ColumnIndex("Accrual Rate")).Text.Replace("%", "")) _
*
(e.Cell.Row.Cells(ColumnIndex("Beginning CV")).Text.Replace("$", "").Replace(",", ""))) _
/ 12
e.Cell.Row.Cells(ColumnIndex("Interest")).Value = decInterest
'Solves the ending balance Formula (begbal + interest + Advances .....
(e.Cell.Row.Cells(ColumnIndex("Beginning CV")).Text.Replace("$", "").Replace(",", ""))) + _
(e.Cell.Row.Cells(ColumnIndex("Advances")).Text.Replace("$", "").Replace(",", ""))) + _
(e.Cell.Row.Cells(ColumnIndex("Interest")).Text.Replace("$", "").Replace(",", ""))) + _
(e.Cell.Row.Cells(ColumnIndex("Gains Loss On Payoff")).Text.Replace("$", "").Replace(",", ""))) + _
(e.Cell.Row.Cells(ColumnIndex("Adjustments")).Text.Replace("$", "").Replace(",", ""))) - _
(e.Cell.Row.Cells(ColumnIndex("Provisions")).Text.Replace("$", "").Replace(",", ""))) + _
(e.Cell.Row.Cells(ColumnIndex("Recoveries")).Text.Replace("$", "").Replace(",", ""))) - _
(e.Cell.Row.Cells(ColumnIndex("Collections")).Text.Replace("$", "").Replace(",", "")))
e.Cell.Row.Cells(ColumnIndex("Ending CV")).Value = eBalance
.Session.Item("MethodValueList")
Sub