Gwt getCellForEvent flexTable [英] Gwt getCellForEvent flexTable

查看:112
本文介绍了Gwt getCellForEvent flexTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将addValueChangeHandler函数添加到flexTable中的TextBox。
但是当我添加以下代码时:
int rowIndex = tableImages.getCellForEvent(event).getRowIndex();
我使用这种方法知道当前行是否存在ClickEvent。

该方法对于ValueChangeEvent,
是不可接受的,所以我怎么能知道改变的单元格的行索引是什么?
谢谢。

解决方案

好的,因为它需要一个Cell本身,而不是TextBox或事件值。
您可以做什么,是:


  1. 通过 event.getSource() / code>

  2. 至少将其转换为 Widget (尽管假设它是一个文本框是安全的) Widget sourceWidget =(Widget)event.getSource();

  3. 获取源窗口小部件的元素 parent sourceWidget.getElement()。getParent();



  4. 通过这种方式, 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:

    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

    这篇关于Gwt getCellForEvent flexTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆