我有一个 CellTable,我想在单击添加按钮时将多个链接添加到一行。现在我面临的问题是,当我单击添加按钮时,链接将添加到该列中的所有行。不知何故,感觉就像我只能将内容添加到列中。
// shows project column
final MultipleLinkTextCell projectCell = new MultipleLinkTextCell();
final Column<Booking, String> projectColumn = new Column<Booking, String>(
projectCell) {
@Override
public String getValue(Booking project) {
return "";
}
};
getView().getTimeTable().addColumn(projectColumn, "Tasks");
带有按钮的示例
@Override
protected void render(com.google.gwt.cell.client.Cell.Context context,
SafeHtml data, SafeHtmlBuilder sb) {
String string = "";
for (int i = 0; i < value; i++) {
string += "<button type=\"button\" style=\" height:20px; width:22px\">";
}
sb.appendHtmlConstant(string);
if (data != null) {
sb.append(data);
}
}
我正在考虑使用 Anchor 小部件,因为我可以使用它从 gwtp 处理 placemanager。但我仍然不知道如何将小部件添加到特定行。
//更新:我现在这样做了,它可以工作,但最好使用revealmanager。硬编码链接有点糟糕,因为当我更改网络服务器时,我总是需要更改对链接的引用。我得到一个字符串,其中有几个由逗号分隔的值。
@Override
protected void render(com.google.gwt.cell.client.Cell.Context context,
SafeHtml data, SafeHtmlBuilder sb) {
String stringData = data.asString();
String[] splitResult = stringData.split(",");
for (int i = 0; i < splitResult.length; i++) {
if (!splitResult[i].equals("")) {
sb.appendHtmlConstant("<div><a href=\"http://127.0.0.1:8888/gwtpTimeTracking.html?gwt.codesvr=127.0.0.1:9997#project;projectid="+splitResult[i].substring(0, 7)+"\">"
+ splitResult[i].substring(0, 7) + "</a></div>");
}
}