[英]GWT CELLTABLE : How to add column in celltable which is combination of non-editable text + hyperlink
我想在單元格表的列中添加鏈接,即“ validationStatus”,當值無效時,某些值也是“有效”以及“無效”,然后我想使鏈接無效(如何操作),而當值有效時,我想要以文字形式顯示
如何在單元格表的特定列中添加鏈接?
我要添加的列是不可編輯文本(有效)+超鏈接(無效)的組合(如果有)。
大概您已經以某種方式將這些值的某種列表與表的每一行相關聯。 擴展Column類並將其設置為顯示TextCell。 重寫Column類中的render方法,以便在呈現這些值時檢查其有效性,並為錨點附加SafeHtml(無效值是鏈接),或者將純轉義文本附加(不包含有效值)鏈接)。 將此Column子類添加到表中。
示例代碼:有效:)
public class CustomColumn extends Column<Record, String>{
public CustomColumn(Cell<String> cell) {
super(cell);
// TODO Auto-generated constructor stub
}
@Override
public void render(Cell.Context context, Record object, com.google.gwt.safehtml.shared.SafeHtmlBuilder sb) {
super.render(context, object, sb);
String validationStatus= object.getValidationStatus();
if(validationStatus.equals("Invalid") ){
sb.appendHtmlConstant("<a href='http://www.google.com'> Invalid </a>");
}else if(validationStatus.equals("Valid")){
sb.appendEscaped("Valid");
}
}
@Override
public String getValue(Car object) {
// TODO Auto-generated method stub
return null;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.