2012-05-14 2 views
2
  1. Je souhaite créer un CellTable. Mais les colonnes de la table de cellule doivent être basées sur la réponse du serveur. Je reçois la réponse du serveur en tant que liste.Comment créer CellTable en fonction de la réponse du serveur

    No of Columns = Size of the list. 
    
  2. L'en-tête de colonne CellTable doit correspondre à la valeur du serveur. Par ex. Réponse du serveur: List<Contacts> contacts

    L'en-tête doit être contacts.getName().

Répondre

1

Je l'ai réalisé avec le code suivant.

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

Cordialement, Gnik

0

Utilisation CellList avec un AsyncDataProvider:

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

est ici plein example et docs.

+0

Merci Andreï. Mais je dois utiliser CellTable et non CellList. CellTable est l'exigence de notre client. – Prince

+0

En tout cas, utilisez 'AsyncDataProvider'. Voici applicable [exemple] (http://www.mytechtip.com/2010/11/gwt-celltable-example-using_8168.html). – kapand

Questions connexes