Gwt getCellForEvent flexTable

倾然丶 夕夏残阳落幕 提交于 2019-12-13 01:12:56

问题


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:


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



来源:https://stackoverflow.com/questions/35460647/gwt-getcellforevent-flextable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!