Hi, see
http://stackoverflow.com/questions/4691801/how-can-i-render-a-clickabletextcell-as-an-anchor-in-a-gwt-celltable

2012/8/22 Magnus <[email protected]>

> Hi,
>
> I know how to add anchors to a cell using SafeHtml, but the clickHandler
> of the anchors is not triggered.
>
> Below is how I create the anchors. How can I do that with CellTable?
>
> Thanks
> Magnus
>
>
>
>   Column<MyData,SafeHtml> col_Action = new Column<MyData,SafeHtml>(new
> SafeHtmlCell())
>   {
>    @Override
>    public SafeHtml getValue (MyData obj)
>    {
>     SafeHtmlBuilder sb = new SafeHtmlBuilder();
>     Panel p = createActionPanel (obj);
>     String t = p.toString ();
>     sb.appendHtmlConstant (t);
>     return sb.toSafeHtml();
>    }
>   };
>
>  private Panel createActionPanel (MyData data)
>  {
>   HorizontalPanel p = new HorizontalPanel ();
>   Anchor a;
>
>   a = createAnchor ("Open","open",data.idx);
>   p.add (a);
>
>   a = createAnchor ("Edit","edit",data.idx);
>   p.add (a);
>
>   ...
>
>   return (p);
>  }
>
>  private Anchor createAnchor (String label,String command,int idx)
>  {
>   Anchor a = new Anchor (label);
>
>   a.addClickHandler(this);
>   Element e = a.getElement();
>
>   e.setAttribute("command",command);
>   e.setAttribute("index",Integer.toString(idx));
>
>   return (a);
>  }
>
>  @Override
>  public void onClick(ClickEvent evt)
>  {
>   Window.alert("never called!");
>
>   Object o = evt.getSource();
>
>   if (o == null)
>    return;
>
>   if (!(o instanceof Anchor))
>    return;
>
>   Anchor a = (Anchor) o;
>
>   int idx = Integer.parseInt(a.getElement().getAttribute("index"));
>   String c = a.getElement().getAttribute("command");
>
>   if (command.equals ("open"))
>   {
>    openMyData (idx);
>   }
>  }
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/NuD9scvbZqQJ.
> 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