Search code examples
gwtgwt2gwt-2.2-celltablecelltablegwt-celltable

How to create CellTable based on the response from the server


  1. I want to create a CellTable. But Columns of the celltable should be based on the response from the server. I'm getting the server response as List.

    No of Columns = Size of the list. 
    
  2. CellTable column header should be the value from the server. For ex. Server response: List<Contacts> contacts

    Header should be contacts.getName().


Solution

  • I achieved it by the following code.

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

    Regards, Gnik