I have a grid where the user can add a row by pressing a button. What this does is adds a new row to the grid with a dummy id and puts the 1st cell of the new row into edit mode.
Next the user types in some data (a product number in this case) in the 1st cell and when the update event for the row is fired, my server-side code looks up the product and populates the rest of the cells with data specific to the product (name, unit price etc.).
The problem occurs when the user instead of ending the editing of the 1st cell with ENTER presses TAB.
When TAB is used the focus goes to the 2nd cell, update for the row is fired (due to the update of the 1st cell) and the data retrieved as supposed to, BUT, when the user TABs away from the 2nd cell on to the 3rd cell, the data in the 2nd cell disappears.
If I refresh the page forcing a re-rendering of the grid, the text in the 2nd cell is there, but not until I do exactly that, refresh.
I “think” this is what happens, but don’t know how to handle it:
- new row with dummy id inserted.
- cell 1 is updated by user. (ending edit mode with either Enter or Tab).
- data processor sends updated data from cell 1 to server-side code.
- server-side code performs the update with data from cell 1 and a lookup retrieving the rest of the product info.
- server-side code sends reply back to the data processor indicating that the update was successful along with some additional data to fill into the rest of the cells of the updated row.
- data processor updates the rest of the cells and takes the row out of “I’m being updated”-mode.
During pt. 2, the user can either end his update of cell 1 with ENTER or with TAB.
If ENTER is used, everything works perfectly, BUT when TAB is used it screws up the data in cell 2 - Probably because when focus leaves cell 1 the update action for the row is fired and cell 2 goes into edit mode before the data processor has received the status of the update request for cell 1 and taken the row out of “I’m being updated”-mode again.
So, when the update of cell 1 is complete (which is fairly quick) cell 2 is populated with data from the data processor, but while being in edit mode, due to the users TAB action. Once the user tabs away from cell 2 and on to cell 3, the data in cell 2 is gone.
Any ideas as to why this is happening and how to avoid it?