M
- the model typepublic abstract class AbstractGridFilters<M> extends Object implements ComponentPlugin<Grid<M>>
Provides an abstract base class that applies filters to the rows in a grid.
A filter is applied to a grid to reduce the amount of information that is displayed, thus highlighting the information of interest to the user. A filter is generally invoked from a header menu.
The filters can be applied locally using Store
filtering or passed to a remote data source using a
FilterPagingLoadConfig
. To enable local filtering, use setLocal(true)
. To enable remote
filtering, use the AbstractGridFilters(Loader)
form of the constructor.
To add a filter to a Grid
column, create an instance of a concrete subclass of Filter
, passing to the
constructor the ValueProvider
for the column, then add the filter to a GridFilters
using
addFilter(Filter)
and invoke initPlugin(Grid)
. The filter then appears in the
grid header menu item for any column that uses the supplied value provider.
Derived classes must provide an implementation of getStore()
.
Modifier and Type | Class and Description |
---|---|
class |
AbstractGridFilters.DefaultGridFilterMessages
The default locale-sensitive messages used by this class.
|
static interface |
AbstractGridFilters.GridFilterMessages
The locale-sensitive messages used by this class.
|
static interface |
AbstractGridFilters.GridFiltersAppearance |
Modifier and Type | Field and Description |
---|---|
protected ColumnModel<M> |
columnModel |
protected Store.StoreFilter<M> |
currentFilter |
protected Grid<M> |
grid |
protected Loader<FilterPagingLoadConfig,?> |
loader |
protected Store<M> |
store |
Constructor and Description |
---|
AbstractGridFilters()
Creates grid filters that are applied locally.
|
AbstractGridFilters(AbstractGridFilters.GridFiltersAppearance appearance)
Creates grid filters that are applied locally.
|
AbstractGridFilters(Loader<? extends FilterPagingLoadConfig,?> loader)
Creates grid filters to be applied remotely.
|
AbstractGridFilters(Loader<? extends FilterPagingLoadConfig,?> loader,
AbstractGridFilters.GridFiltersAppearance appearance)
Creates grid filters to be applied remotely.
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(Filter<M,?> filter)
Adds a filter.
|
protected void |
bindColumnModel(ColumnModel<M> columnModel) |
protected void |
bindStore(Store<M> store) |
List<FilterConfig> |
buildQuery(List<Filter<M,?>> filters)
Builds a query consisting of a list of loader filter configurations from a list of grid filters.
|
void |
cleanParams(FilterPagingLoadConfig config)
Removes filter related query parameters from the provided object.
|
void |
clearFilters()
Turns all filters off.
|
AbstractGridFilters.GridFiltersAppearance |
getAppearance() |
Filter<M,?> |
getFilter(String path)
Returns the filter based on the value provider path.
|
List<Filter<M,?>> |
getFilterData()
Returns a list of the currently active filters.
|
Loader<FilterPagingLoadConfig,?> |
getLoader()
Returns the loader.
|
protected Filter<M,?> |
getMenuFilter(CheckChangeEvent<CheckMenuItem> event) |
AbstractGridFilters.GridFilterMessages |
getMessages()
Returns the locale-sensitive messages used by this class.
|
protected Store.StoreFilter<M> |
getModelFilter() |
protected abstract Store<M> |
getStore()
Returns the store used by the grid filters.
|
protected void |
handleBeforeLoad(BeforeLoadEvent<FilterPagingLoadConfig> event) |
protected void |
handleLoad(LoadEvent event) |
void |
initPlugin(Grid<M> component)
Initializes the plugin.
|
boolean |
isAutoReload()
Returns true if auto load is enabled.
|
protected boolean |
isLocal()
Returns true if the grid filters are to be applied locally.
|
protected void |
onCheckChange(CheckChangeEvent<CheckMenuItem> event) |
protected void |
onContextMenu(HeaderContextMenuEvent event) |
protected void |
onStateChange(Filter<M,?> filter) |
void |
reload() |
void |
removeAll()
Removes all filters.
|
void |
removeFilter(Filter<M,?> filter)
Removes the given filter.
|
void |
setAutoReload(boolean autoLoad)
Tree to reload the datasource when a filter change happens (defaults to true).
|
protected void |
setLocal(boolean local)
True to use Store filter functions (local filtering) instead of the default server side filtering (defaults to
false).
|
void |
setUpdateBuffer(int updateBuffer)
Number of milliseconds to defer store updates since the last filter change (defaults to 500).
|
void |
updateColumnHeadings() |
protected ColumnModel<M> columnModel
protected Store.StoreFilter<M> currentFilter
protected Loader<FilterPagingLoadConfig,?> loader
public AbstractGridFilters()
setLocal(true)
.public AbstractGridFilters(AbstractGridFilters.GridFiltersAppearance appearance)
setLocal(true)
.appearance
- the appearancepublic AbstractGridFilters(Loader<? extends FilterPagingLoadConfig,?> loader)
FilterPagingLoadConfig
during the loading processing and passed by the Loader
to the
DataProxy
so that they are available for the remote data source to use as needed.loader
- the remote loaderpublic AbstractGridFilters(Loader<? extends FilterPagingLoadConfig,?> loader, AbstractGridFilters.GridFiltersAppearance appearance)
FilterPagingLoadConfig
during the loading processing and passed by the Loader
to the
DataProxy
so that they are available for the remote data source to use as needed.loader
- the remote loaderappearance
- the appearancepublic List<FilterConfig> buildQuery(List<Filter<M,?>> filters)
filters
- the filterspublic void cleanParams(FilterPagingLoadConfig config)
config
- the load configpublic void clearFilters()
removeAll()
).public AbstractGridFilters.GridFiltersAppearance getAppearance()
public Filter<M,?> getFilter(String path)
path
- the pathpublic List<Filter<M,?>> getFilterData()
public Loader<FilterPagingLoadConfig,?> getLoader()
null
for local filteringpublic AbstractGridFilters.GridFilterMessages getMessages()
public void initPlugin(Grid<M> component)
ComponentPlugin
initPlugin
in interface ComponentPlugin<Grid<M>>
component
- the target componentpublic boolean isAutoReload()
public void reload()
public void removeAll()
public void removeFilter(Filter<M,?> filter)
filter
- the filter to be removedpublic void setAutoReload(boolean autoLoad)
autoLoad
- true to enable auto reloadpublic void setUpdateBuffer(int updateBuffer)
updateBuffer
- the buffer in millisecondspublic void updateColumnHeadings()
protected void bindColumnModel(ColumnModel<M> columnModel)
protected Filter<M,?> getMenuFilter(CheckChangeEvent<CheckMenuItem> event)
protected Store.StoreFilter<M> getModelFilter()
protected abstract Store<M> getStore()
protected void handleBeforeLoad(BeforeLoadEvent<FilterPagingLoadConfig> event)
protected void handleLoad(LoadEvent event)
protected boolean isLocal()
protected void onCheckChange(CheckChangeEvent<CheckMenuItem> event)
protected void onContextMenu(HeaderContextMenuEvent event)
protected void setLocal(boolean local)
local
- true for localCopyright © 2018. All rights reserved.