Reviewers: pdr,

Description:
Adding an Async SortHandler that can be used with AsyncDataProvider.
When a table is sorted, it called the setVisibleRangeAndClear() method
to clear the current data and send an event to the AsyncDataProvider to
provide new information.


Please review this at http://gwt-code-reviews.appspot.com/1258801/show

Affected files:
  M user/src/com/google/gwt/user/cellview/client/ColumnSortEvent.java


Index: user/src/com/google/gwt/user/cellview/client/ColumnSortEvent.java
===================================================================
--- user/src/com/google/gwt/user/cellview/client/ColumnSortEvent.java (revision 9493) +++ user/src/com/google/gwt/user/cellview/client/ColumnSortEvent.java (working copy)
@@ -18,6 +18,7 @@
 import com.google.gwt.event.shared.EventHandler;
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.gwt.event.shared.HasHandlers;
+import com.google.gwt.view.client.HasData;

 import java.util.Collections;
 import java.util.Comparator;
@@ -41,6 +42,25 @@
      * @param event the {...@link ColumnSortEvent} that was fired
      */
     void onColumnSort(ColumnSortEvent event);
+  }
+
+  /**
+ * A default handler used with views attached to asynchronous data providers
+   * such as {...@link AsyncDataProvider}. This handler calls
+ * {...@link HasData#setVisibleRangeAndClearData(com.google.gwt.view.client.Range, boolean)}, + * which clears the current data and triggers the data provider's range change
+   * handler.
+   */
+  public static class AsyncHandler implements Handler {
+    private final HasData<?> hasData;
+
+    public AsyncHandler(HasData<?> hasData) {
+      this.hasData = hasData;
+    }
+
+    public void onColumnSort(ColumnSortEvent event) {
+      hasData.setVisibleRangeAndClearData(hasData.getVisibleRange(), true);
+    }
   }

   /**


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to