com.vaadin.client.widget.grid.datasources
Class ListSorter<T>

java.lang.Object
  extended by com.vaadin.client.widget.grid.datasources.ListSorter<T>
Type Parameters:
T - Grid row data type

public class ListSorter<T>
extends java.lang.Object

Provides sorting facility from Grid for the ListDataSource in-memory data source.

Since:
7.4
Author:
Vaadin Ltd

Constructor Summary
ListSorter(Grid<T> grid)
           
 
Method Summary
 void clearComparators()
          Remove all comparator mappings.
<C> java.util.Comparator<C>
getComparator(Grid.Column<C,T> column)
          Retrieve the comparator assigned for a specific grid column.
 void removeFromGrid()
          Detach this Sorter from the Grid.
<C> void
setComparator(Grid.Column<C,T> column, java.util.Comparator<C> comparator)
          Assign or remove a comparator for a column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListSorter

public ListSorter(Grid<T> grid)
Method Detail

removeFromGrid

public void removeFromGrid()
Detach this Sorter from the Grid. This unregisters the sort event handler which was used to apply sorting to the ListDataSource.


setComparator

public <C> void setComparator(Grid.Column<C,T> column,
                              java.util.Comparator<C> comparator)
Assign or remove a comparator for a column. This comparator method, if defined, is always used in favour of 'natural' comparison of objects (i.e. the compareTo of objects implementing the Comparable interface, which includes all standard data classes like String, Number derivatives and Dates). Any existing comparator can be removed by passing in a non-null GridColumn and a null Comparator.

Parameters:
column - a grid column. May not be null.
comparator - comparator method for the values returned by the grid column. If null, any existing comparator is removed.

getComparator

public <C> java.util.Comparator<C> getComparator(Grid.Column<C,T> column)
Retrieve the comparator assigned for a specific grid column.

Parameters:
column - a grid column. May not be null.
Returns:
a comparator, or null if no comparator for the specified grid column has been set.

clearComparators

public void clearComparators()
Remove all comparator mappings. Useful if the data source has changed but this Sorter is being re-used.



Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.