Domanda

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 ?

È stato utile?

Soluzione

This is the simple way:

        table.addClickHandler(new ClickHandler() { 
            @Override 
            public void onClick(ClickEvent event) {  
                 int rowIndex = table.getCellForEvent(event).getRowIndex();
            } 
        });  
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top