I have a datagrid with one editable column, like this:
[ id ] [ label ] [ cost ]
 [apple] 
 [pear] 
 [peach] 
The 'cost' column is editable, and when it is changed I need
to update our database with the new value. For example, if the user
changes the value for row 1 from '10' to '14', I need to tell our
database: 'update the item with row id '1' to have value 14'.
I can't figure out how to reliably get the row 'id' value for
the row that was updated. If I capture the itemEditEnd
DataGridEvent, I can get the event.rowIndex value, but this does
not necessarily correspond to the correct row index of the
dataProvider. For example, if the user has re-sorted the datagrid
by clicking on a column header, then the event.rowIndex value gives
me the display index, but not the correct dataProvider index.
Furthermore, I can't seem to find a way to get the values for the
other columns through the datagrid object directly.
Does anyone know how I can access the values for the other
columns in the same row that was updated?
Turns out that the problem was because I was binding my
DataGrid control to the 'children()' method of an XML object. I
created an XMLListCollection object and bound the datagrid to that,
and the collection object now gets resorted when the datagrid gets
resorted, so the rowIndex works fine.
I also figured out that I can access any other column like
Where 'event' is the DataGridEvent object, 'data' is an array
of all the fields for that row, and 'fieldname' is the name of the
field for the column I want.