Gwt getCellForEvent flexTable [英] Gwt getCellForEvent flexTable
问题描述
我试图将addValueChangeHandler函数添加到flexTable中的TextBox。
但是当我添加以下代码时:
int rowIndex = tableImages.getCellForEvent(event).getRowIndex();
我使用这种方法知道当前行是否存在ClickEvent。
该方法对于ValueChangeEvent,
是不可接受的,所以我怎么能知道改变的单元格的行索引是什么?
谢谢。
好的,因为它需要一个Cell本身,而不是TextBox或事件值。
您可以做什么,是:
- 通过
event.getSource() / code>
- 至少将其转换为
Widget
(尽管假设它是一个文本框是安全的)Widget sourceWidget =(Widget)event.getSource();
- 获取源窗口小部件的元素 parent
sourceWidget.getElement()。getParent();
- Get the event Source via
event.getSource()
- Cast it to
Widget
at least (though it's safe to assume it's a textBox)Widget sourceWidget = (Widget)event.getSource();
- Get the source widget's element's parent
sourceWidget.getElement().getParent();
通过这种方式, code>< td> 将textBox嵌入到单元格中。
然后,您可以获取表格的CellSize并在循环中查找单元格的索引,比较< td>
元素与您表格的单元格一起获得。
请告诉我它是否解决了您的问题
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.
Well yes, because it needs a Cell itself, not a TextBox or event value. What you can do, is:
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
这篇关于Gwt getCellForEvent flexTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!