Friday, January 31, 2014

Re: GWT Multi columns sort with AsyncDataProvider

I have the same problem. I do not think it is advisable sorting AsyncDataProvider on the client side. I would suggest you to perform the sorting at server side and make the rpc call to return the data. 

Thanks
Ashish Tyagi

On Tuesday, July 16, 2013 7:10:19 AM UTC-4, zakaria otmani wrote:
i have a table contains 3 columns, when the user clicks in one of them the table should be sorted, i'm using AsyncDataProvider, the sort for the first column works fine, so i should do the same to the others columns. this is the code :

AsyncDataProvider<PermisoUI> providerPerfiles = new AsyncDataProvider<PermisoUI>() {        @Override      protected void onRangeChanged(HasData<PermisoUI> display) {            if(sortedPermiso) {              sortedPermiso=false;              class TipoCuotasComparator implements Comparator<Object> {                  public int compare(Object l1, Object l2) {                      PermisoUI o1 = (PermisoUI) l1;                      PermisoUI o2 = (PermisoUI) l2;                      return o2.getId().compareTo(o1.getId());                    }              }              Collections.sort(listPermisos, new TipoCuotasComparator());          }else {              sortedPermiso = true;              class TipoCuotasComparator implements Comparator<Object> {                  public int compare(Object l1, Object l2) {                      PermisoUI o1 = (PermisoUI) l1;                      PermisoUI o2 = (PermisoUI) l2;                      return o1.getId().compareTo(o2.getId());                  }              }              Collections.sort(listPermisos, new TipoCuotasComparator());          }            int start = display.getVisibleRange().getStart();          int end = start + display.getVisibleRange().getLength();          end = end >= listPermisos.size() ? listPermisos.size() : end;          List<PermisoUI> sub = listPermisos.subList(start, end);          updateRowData(start, sub);        }  };        providerPerfiles.addDataDisplay(CellTblPermisos);    //Sorting Column  AsyncHandler columnSortAplHandler = new AsyncHandler(CellTblPermisos);  CellTblPermisos.addColumnSortHandler(columnSortAplHandler);  CellTblPermisos.getColumnSortList().push(permisoColumn);          providerPerfiles.addDataDisplay(CellTblPermisos);  providerPerfiles.updateRowCount(listPermisos.size(), true);  PPerfil.clear();  PPerfil.add(CellTblPermisos);

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment