I want to add link in my celltable's column i.e"validationStatus" some values are "valid" as well as "invalid" when value is invalid then I want to make invalid as link (How to ?) & when value is valid then I want to make it as text
How to add link in celltables particular column ?
I want to a开发者_开发技巧dd Column which is combination of non-editable text(valid) + hyperlink (invalid)if any.
Presumably you have some sort of list of these values associated in some fashion with each row of your table. Extend the Column class and set it to display a TextCell. Override the render method in your Column class so that when it renders these values, it checks them for validity, and either appends the SafeHtml for an anchor (invalid values that are links), or it appends plain escaped text (valid values that are not links). Add this Column subclass to your table.
Sample code: It works :)
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;
}
精彩评论