在GWT celltable中添加超链接 [英] Adding Hyperlink in GWT celltable
问题描述
我试图在celltable中添加一个超链接,并点击那个链接,我想调用一个方法。
I am trying to add a hyperlink in celltable and on clicking on that link i want to call a method.
用下面的代码我得到一个超链接我的celltable正确,但我无法通过单击链接调用方法,当我单击链接时,它会将我带到上一页。
with the below code i am getting a hyperlink in my celltable correctly but I am not able to call a method by clicking on the link , when i click the link it takes me to the previous page.
任何解决方案
Hyperlink link = new Hyperlink("Delete","");
Column<EmployerJobs, Hyperlink> linkColumn =
new Column<EmployerJobs, Hyperlink>(new HyperLinkCell()) {
@Override
public Hyperlink getValue(EmployerJobs list) {
link.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
deleteJobs(list);
}
});
return link;
}
});
推荐答案
除了HyperlinkCell,您可以使用 ClickableTextCell ,一个ButtonCell或一个 ActionCell 。
Instead of a HyperlinkCell you can either use a ClickableTextCell, a ButtonCell or an ActionCell.
ClickableTextCell :
Column<EmployerJobs, String> linkColumn =
new Column<EmployerJobs, String>(new ClickableTextCell()) {
@Override
public String getValue(EmployerJobs object) {
return TEXT_TO_DISPLAY;
}
},'linkheadertext');
linkColumn.setFieldUpdater(new FieldUpdater<EmployerJobs, String>() {
@Override
public void update(int index, EmployerJobs object, String value) {
deleteJobs(object);
}
});
ButtonCell :
ButtonCell:
Column<EmployerJobs, String> buttonColumn =
new Column<EmployerJobs, String>(new ButtonCell()) {
@Override
public String getValue(EmployerJobs object) {
return TEXT_TO_DISPLAY;
}
},'linkheadertext');
buttonColumn.setFieldUpdater(new FieldUpdater<EmployerJobs, String>() {
@Override
public void update(int index, EmployerJobs object, String value) {
deleteJobs(object);
}
});
ActionCell :
ActionCell:
Column<EmployerJobs, EmployerJobs> actionColumn =
new Column<EmployerJobs, EmployerJobs>(new ActionCell<EmployerJobs>("Click Me",
new ActionCell.Delegate<EmployerJobs>() {
@Override
public void execute(EmployerJobs jobs) {
deleteJobs(jobs);
}
})
{
@Override
public EmployerJobs getValue(EmployerJobs object) {
return object;
}
},'linkheadertext');
查看CellSample showcase 了解更多信息。
Check out the CellSample showcase for more infos.
这篇关于在GWT celltable中添加超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!