You can extend CellTable and overwritte onBrowserEvent2.

 @Override
  protected void onBrowserEvent2(Event event) {
    super.onBrowserEvent2(event);

    String eventType = event.getType();
    boolean isClick = "click".equals(eventType);

    // Get the event target.
    EventTarget eventTarget = event.getEventTarget();
    if (!Element.is(eventTarget)) {
      return;
    }
    final Element target = event.getEventTarget().cast();

    if (isClick) {
      int columnClicked = getCellIndex(target);
      boolean isExcludedColumn =
          this.excludedColumns != null
              && (Arrays.binarySearch(this.excludedColumns, columnClicked)
>= 0);
      if (!"input".equalsIgnoreCase(target.getTagName())
          && !isExcludedColumn) {
        T item = getCurrentSelectedItem(target);
       //do something
      }
    }
  }

2011/8/31 Foermchen82 <[email protected]>

> Hi,
>
> I want to handle click events on cell table rows. But i'm not able to
> do this!
>
> I tried the following code:
>
> CellTable<MyObject> table = new CellTable<MyObject>();
> final SingleSelectionModel<MyObject> model = new
> SingleSelectionModel<MyObject>();
>                table.setSelectionModel(model);
>
>                table.addHandler(new ClickHandler() {
>
>                        @Override
>                        public void onClick(ClickEvent event) {
>                                try{
>
>  Window.alert(model.getSelectedObject());
>                                }
>                                catch(Exception e){
>                                        System.out.println(e);
>                                }
>                        }
>                }, ClickEvent.getType());
>
> The problem is, that I try to get the object of the row on which I
> have clicked. But on the click, the row under the mouse is actually
> not selected. so the popup shows the wrong object.
>
> How can I retreive the object under the mouse?
>
> Kind regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to