问题描述
在所有的
i中都需要一个简单的例子,告诉我如何将ClickableTextCells的列添加到cellTable中。
$ b
谢谢。
> // ClickableTextCell
ClickableTextCell anchorcolumn = new ClickableTextCell();
table.addColumn(addColumn(anchorcolumn,new GetValue< String>(){
public String getValue(Contact contact){
returnClick+ contact.anchor;
}
},new FieldUpdater< Contact,String>(){
public void update(int index,Contact object,String value){
Window.alert(You clicked+ object.name );
}
}),Anchor);
私人< C>栏<联系人,C> addColumn(Cell< C> cell,final GetValue< C> getter,
FieldUpdater< Contact,C> fieldUpdater){
Column< Contact,C> column = new Column< Contact,C>(cell){
@Override
public C getValue(Contact object){
return getter.getValue(object);
}
};
column.setFieldUpdater(fieldUpdater);
返回列;
}
private static interface GetValue< C> {
C getValue(联系人联系人);
}
//表示联系人的简单数据类型。
私有静态类联系{
私有最终字符串地址;
private final String name;
private final字符串锚;
public Contact(String name,String address,String anchor){
this.name = name;
this.address = address;
this.anchor = anchor;
}
}
hi alli need a simple example show me how to add column of ClickableTextCells to cellTable
thanks.
this is the solution if you need to add clickableTextCell to cellTable
// ClickableTextCell
ClickableTextCell anchorcolumn = new ClickableTextCell();
table.addColumn(addColumn(anchorcolumn, new GetValue<String>() {
public String getValue(Contact contact) {
return "Click " + contact.anchor;
}
}, new FieldUpdater<Contact, String>() {
public void update(int index, Contact object, String value) {
Window.alert("You clicked " + object.name);
}
}), "Anchor");
private <C> Column<Contact, C> addColumn(Cell<C> cell,final GetValue<C> getter,
FieldUpdater<Contact, C> fieldUpdater) {
Column<Contact, C> column = new Column<Contact, C>(cell) {
@Override
public C getValue(Contact object) {
return getter.getValue(object);
}
};
column.setFieldUpdater(fieldUpdater);
return column;
}
private static interface GetValue<C> {
C getValue(Contact contact);
}
// A simple data type that represents a contact.
private static class Contact {
private final String address;
private final String name;
private final String anchor;
public Contact(String name, String address, String anchor) {
this.name = name;
this.address = address;
this.anchor = anchor;
}
}
这篇关于如何将ClickableTextCells的列添加到cellTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!