5

I have a FlexTable in GWT, and I would like an event to happen at the click of a single cell or in a group of cells. Can it be done?

Thank you very much.

Alex
  • 8,093
  • 6
  • 49
  • 79
Sebe
  • 63
  • 1
  • 6

1 Answers1

11

Here is the simplest solution

new ClickHandler() {

    @Override
    public void onClick(ClickEvent event) {
        int cellIndex = flexTable.getCellForEvent(event).getCellIndex();
        int rowIndex = flexTable.getCellForEvent(event).getRowIndex();
    }
};
Alex
  • 8,093
  • 6
  • 49
  • 79
  • 1
    Also don't forget to check for null returned from getCellForEvent(event) method before calling getRowIndex() or getCellIndex() – Ilia Akhmadullin Dec 23 '10 at 19:35
  • If there is an event on table it can't be null –  Dec 24 '10 at 04:54
  • getCellForEvent will return null in case you have set cellSpacing and you click into area of cell spacing! Tested it in GWT 2.7.0 – Piro Jun 02 '16 at 07:42