Class ListSorter<T>
- java.lang.Object
-
- com.vaadin.client.widget.grid.datasources.ListSorter<T>
-
- Type Parameters:
T- Grid row data type
public class ListSorter<T> extends Object
Provides sorting facility from Grid for theListDataSourcein-memory data source.- Since:
- 7.4
- Author:
- Vaadin Ltd
-
-
Constructor Summary
Constructors Constructor Description ListSorter(Grid<T> grid)Constructs a sorting facility for the given Grid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearComparators()Remove all comparator mappings.<C> Comparator<C>getComparator(Grid.Column<C,T> column)Retrieve the comparator assigned for a specific grid column.voidremoveFromGrid()Detach this Sorter from the Grid.<C> voidsetComparator(Grid.Column<C,T> column, Comparator<C> comparator)Assign or remove a comparator for a column.
-
-
-
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, 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.- Type Parameters:
C- the column data type- 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> Comparator<C> getComparator(Grid.Column<C,T> column)
Retrieve the comparator assigned for a specific grid column.- Type Parameters:
C- the column data type- 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.
-
-