Friday, May 13, 2016

Re: Sorting cell table columns populated from gwt rpc not working

Hello,

Thank you. It work perfectly now.

Have a nice day,
Andrei

vineri, 13 mai 2016, 21:12:40 UTC+3, Olar Andrei a scris:

Hello, I'm pretty new to GWT


I have a problem trying to sort specific columns from a cell table, whcih is populated from the DB, using RPC. Basically I'm trying to sort the family name column alphabetically, and it's just not working. Table gets fully populated, but sorting does not work.

Any ideas why ?


Thanks in advance


// Create the family name column.      final TextColumn<ContactInfo> familyNameColumn = new TextColumn<ContactInfo>() {            @Override          public String getValue(ContactInfo object) {              return object.getFamilyName();          }      };      table.setColumnWidth(familyNameColumn, 20, Unit.PCT);        // Make the family name sortable      familyNameColumn.setSortable(true);      // Add the columns      table.addColumn(familyNameColumn, UserMenuConstants.FAMILY_NAME_COLUMN);      table.addColumn(familyAdministratorColumn, UserMenuConstants.FAMILY_ADMINISTRATOR_COLUMN);      table.addColumn(apartmentNuberColumn, UserMenuConstants.FAMILY_APARTMENT_NUMBER_COLUMN);      table.addColumn(emailColumn, UserMenuConstants.EMAIL_ADDRESS_COLUMN);      table.addColumn(phoneNumberColumn, UserMenuConstants.PHONE_NUMBER_COLUMN);        DBGetContactInfoAsync rpcService = (DBGetContactInfoAsync) GWT.create(DBGetContactInfo.class);      ServiceDefTarget target = (ServiceDefTarget) rpcService;      String moduleRelativeURL = GWT.getModuleBaseURL() + "DBGetContactInfoImpl";      target.setServiceEntryPoint(moduleRelativeURL);        rpcService.getContacts(new AsyncCallback<List<ContactInfo>>() {            @Override          public void onSuccess(List<ContactInfo> result) {                table.setRowCount(result.size());                ListDataProvider<ContactInfo> dataProvider = new ListDataProvider<ContactInfo>();              dataProvider.addDataDisplay(table);                List<ContactInfo> list = dataProvider.getList();              for (ContactInfo contactInfo : result) {                  list.add(contactInfo);              }                ListHandler<ContactInfo> listHandler = new ListHandler<ContactInfo>(result);                listHandler.setComparator(familyNameColumn, new Comparator<ContactInfo>() {                    @Override                  public int compare(ContactInfo o1, ContactInfo o2) {                      return o1.getFamilyName().compareTo(o2.getFamilyName());                  }              });                table.addColumnSortHandler(listHandler);            }            @Override          public void onFailure(Throwable caught) {              ...          }      });



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment