3
votes

I have a CellTable with few columns and two of those columns are TextInputCells. On update of value in this cells, I do a calculation(ex: total) and set the total row's value. I needed to redraw the celltable to immediately display the updated value. The problem I am facing is, when the user is in first text cell and inputs a value and presses tab on keyboard, since the celltable is redrawn, focus is lost from the cell.

What can I do to not lose the focus when the table is redrawn?

Table Structure:

ID         Description   Month1               Month2
expenseId1   Travel      10                    15
expenseId2   Food        40                    50
Subtotal                 50                    65
Misc.                    TextInputCell      TextInputCell
Total                    50                    65

Thanks.

3
Do you already have a solution for your problem? I'm fighting with the same problem and don't have a solution yet. The two answers won't work for me.. - fklappan
Any answer for this? I am still facing this. - vbjain

3 Answers

0
votes

No need to redraw the table after calculating total. You can just call dataProvider.refresh() method on the grid. It will refresh your grid.

0
votes

You have to call setVisibleRange() on celltable

 cellTable.setVisibleRangeAndClearData(cellTable.getVisibleRange(),true); 

You can do like this also

cellTable.setRowData(0, listOfObjs) // where listOfObjs is your changed data

0
votes

This happening because of render cycle. So there is no possibility to save focus. Because every render cycle your view objects are no longer exist. New dom elements took their place.