Hi Jens,
it works great now!
I derived a class GameCommandCell that represents the commands (as anchors)
on a row, which is a game (as you know).
First, I was wondering which type I should pass to AbstractCell. I tried
with SafeHtml, but then I had no access to the row data within
onBrowserEvent. So I used AbstractCell<Game>:
public class GameCommandCell extends AbstractCell<Game>
> Inside the cell you have access to the row value [...]
Well, I had a little bit trouble with the combination of types passed to
the Column and the GameCommandCell. Whatever I did, they did not fit to
each other, since Column.getValue delivers into Cell.render. I didn't want
to use AbstractCell<Game>, because the cell does not represent a "game".
But I found that using AbstractCell<Game> is the only way to have access to
the row data within Cell.render. I also found that using IdentityColumn
gives the cell access to the row:
IdentityColumn<Game> col_Action = new IdentityColumn<Game>(new
GameCommandCell ())
I am not finally happy with this. The cell should represent a set of
commands, not a game. I think I will use an intermediate class "CommandSet"
or something like that and use this as a type for AbstractCell, because
this would be more generic and not restricted to the row type "Game".
> Hope this helps.
It did so! Thank you very much!
Magnus
-----
public class GameCommandCell extends AbstractCell<Game>
{
public GameCommandCell ()
{
super ("click"); // we want click events
}
@Override
public void render (Context context,Game value,SafeHtmlBuilder sb)
{
String t = renderCommand ("O","Open");
sb.appendHtmlConstant(t);
sb.appendHtmlConstant(" ");
t = renderCommand ("E","Edit");
sb.appendHtmlConstant(t);
}
public String renderCommand (String cmd,String lbl)
{
String t = "<a href='javascript:;' style='cursor: hand;' cmd='" + cmd +
"'>" + lbl + "</a>";
return (t);
}
@Override
public void onBrowserEvent (Context context, Element parent,Game
value,NativeEvent event, ValueUpdater<Game> valueUpdater)
{
super.onBrowserEvent(context, parent, value, event, valueUpdater);
EventTarget tgt = event.getEventTarget();
Element e = Element.as(tgt);
String c = e.getAttribute("cmd");
Window.alert("Command: " + c);
}
}
--
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/-/Sxvrzrzi7zQJ.
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.