2
  1. 我想创建一个 CellTable。但是 celltable 的列应该基于服务器的响应。我将服务器响应作为列表。

    No of Columns = Size of the list. 
    
  2. CellTable 列标题应该是来自服务器的值。例如。服务器响应:List<Contacts> contacts

    标题应该是contacts.getName().

4

2 回答 2

1

我通过以下代码实现了它。

          for (Contacts contact : contacts) {
               final String city = contact.getCity();
               final TextColumn<String> addressColumn = new TextColumn<String>() {

                @Override
                public String getValue(Contacts object) {
                    return city;
                }
            };

            cellTable.addColumn(addressColumn, contact.getAddress());
            }

问候, Gnik

于 2012-05-23T12:13:20.573 回答
0

CellListAsyncDataProvider一起使用:

//Create a cellList
@UiField
CellList<Contact> cellList;

//Creating dataProvider and completion of the cellList
@UiFactory
CellList<Contact> makeCellList() {
private AsyncDataProvider<Contact> provider = new AsyncDataProvider<Contact>() {
    @Override
    public void onRangeChanged(final HasData<Contact> display) {
        rpcService.getContact(new AsyncCallback<List<Contact>>() {
               @Override
               public void onSuccess(List<Contact> result) {   
                   display.setRowData(0, result); 
               }
               @Override
               public void onFailure(Exception ex) {
                    //TODO
               }
        });
    }
};

//Adding the cellList to the provider in a constructor
provider.addDataDisplay(cellList);

这是完整的示例文档

于 2012-05-14T12:49:51.143 回答