Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt 如何获取flextable中小部件的行号?_Gwt_Row_Flextable - Fatal编程技术网

Gwt 如何获取flextable中小部件的行号?

Gwt 如何获取flextable中小部件的行号?,gwt,row,flextable,Gwt,Row,Flextable,我在网上找到了这段代码,但不确定它是否是最佳解决方案 public int getWidgetRow(Widget widget, FlexTable table) { for (int row = 0; row < table.getRowCount(); row++) { for (int col = 0; col < table.getCellCount(row); col++) { Widget w = table

我在网上找到了这段代码,但不确定它是否是最佳解决方案

public int getWidgetRow(Widget widget, FlexTable table) {

        for (int row = 0; row < table.getRowCount(); row++) {
          for (int col = 0; col < table.getCellCount(row); col++) {
            Widget w = table.getWidget(row, col);
            if (w == widget) {
              return row;
            }
          }
        }

        return -1;
  }
public int getWidgetRow(小部件小部件,FlexTable表){
对于(int row=0;row
为什么FlexTable没有一个函数来获取其中一个小部件的行号


还有其他更好的解决方案吗?

这是一个简单的方法:

        table.addClickHandler(new ClickHandler() { 
            @Override 
            public void onClick(ClickEvent event) {  
                 int rowIndex = table.getCellForEvent(event).getRowIndex();
            } 
        });  

但我在flextable的一个单元格里有一个按钮。所以我点击按钮&而不是点击flextable的一个单元格。那个么该如何编码呢?现在发生了什么?当你们的按钮点击控件时,并没有进入onClick方法??