Question

I found this code on internet but not sure it is the optimum solution

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;
  }

Why FlexTable does not have a function to get a row no of a widget inside it?

Any other better solution ?

Was it helpful?

Solution

This is the simple way:

        table.addClickHandler(new ClickHandler() { 
            @Override 
            public void onClick(ClickEvent event) {  
                 int rowIndex = table.getCellForEvent(event).getRowIndex();
            } 
        });  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top