문제

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 ?

도움이 되었습니까?

해결책

This is the simple way:

        table.addClickHandler(new ClickHandler() { 
            @Override 
            public void onClick(ClickEvent event) {  
                 int rowIndex = table.getCellForEvent(event).getRowIndex();
            } 
        });  
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top