1
votes

I`m trying to add addValueChangeHandler function to a TextBox inside a flexTable. But when I add this code: int rowIndex = tableImages.getCellForEvent(event).getRowIndex(); I use this method to know the current row in case of a ClickEvent.

the method is not acceptable for ValueChangeEvent, so how can I know what is the row Index for the changed cell? Thank you.

1

1 Answers

0
votes

Well yes, because it needs a Cell itself, not a TextBox or event value. What you can do, is:

  1. Get the event Source via event.getSource()
  2. Cast it to Widget at least (though it's safe to assume it's a textBox) Widget sourceWidget = (Widget)event.getSource();
  3. Get the source widget's element's parent sourceWidget.getElement().getParent();

This way you'll acquire the actual <td> cell your textBox nested in. Then you can getCellFormatter of your table and find the index of the cell in a loop, comparing the <td> element you got with the cells of your table.

Please tell me if it solved your problem