2012-05-14 22 views
2
  1. CellTableを作成したいと思います。しかし、セルテーブルの列は、サーバーからの応答に基づいている必要があります。私はリストとしてサーバーの応答を得ています。サーバーからの応答に基づいてCellTableを作成する方法

    No of Columns = Size of the list. 
    
  2. CellTable列ヘッダーは、サーバからの値であるべきです。 例:サーバーの応答:List<Contacts> contacts

    ヘッダーはcontacts.getName()である必要があります。

答えて

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

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); 

ここexampledocsいっぱいです。

+0

おかげアンドレイ。しかし、CellListではなくCellListを使う必要があります。 CellTableは私たちのクライアントの要件です。 – Prince

+0

とにかく 'AsyncDataProvider'を使います。適用可能です[例](http://www.mytechtip.com/2010/11/gwt-celltable-example-using_8168.html)。 – kapand

関連する問題