T - the type of the data table recordspublic class LocalListDataStore<T> extends Object implements DataStore<T>
DataStore that wraps an in-memory/local list of records allowing
the data table to use features like pagination and sorting| Modifier and Type | Class and Description |
|---|---|
static interface |
LocalListDataStore.SortFunction<T> |
| Constructor and Description |
|---|
LocalListDataStore()
Creates an instance initialized with empty list
|
LocalListDataStore(List<T> data)
Creates an instance initialized with a custom list of data
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRecord(T record)
adds a single record to the current list and updates the data table accordingly
|
void |
addRecords(Collection<T> records)
adds a list of records to the current list and updates the data table accordingly
|
List<T> |
getFilteredRecords() |
HasPagination |
getPagination() |
List<T> |
getRecords() |
RecordsSorter<T> |
getRecordsSorter() |
SearchFilter<T> |
getSearchFilter() |
void |
handleEvent(TableEvent event)
this store will listen to the following events
|
void |
load()
loads the data into the data table
|
void |
onDataChanged(StoreDataChangeListener<T> dataChangeListener)
Adds a listener to handle the
DataChangedEvent events |
void |
removeDataChangeListener(StoreDataChangeListener<T> dataChangeListener)
removes the listener
|
void |
removeRecord(Collection<T> records)
Deprecated.
|
void |
removeRecord(T record)
removes a single record from the current list and updates the data table accordingly
|
void |
removeRecords(Collection<T> records)
removes a list of records from the current list and updates the data table accordingly
|
LocalListDataStore<T> |
setAutoSort(boolean autoSort) |
LocalListDataStore<T> |
setAutoSortBy(String autoSortBy)
set the default column name to initially sort the data list by.
|
LocalListDataStore<T> |
setAutoSortDirection(SortDirection autoSortDirection)
set the default sort direction to initially sort the data list by.
|
void |
setData(List<T> data)
sets new data list overriding the existing one, and clears all filters, then loads it in the
data table
|
LocalListDataStore<T> |
setPagination(HasPagination pagination)
set the pagination component to be used by the data store
|
LocalListDataStore<T> |
setRecordsSorter(RecordsSorter<T> recordsSorter)
Sets the records sorting for this data store
|
LocalListDataStore<T> |
setRecordsSorter(RecordsSorter<T> recordsSorter,
LocalListDataStore.SortFunction<T> sortFunction) |
LocalListDataStore<T> |
setSearchFilter(SearchFilter<T> searchFilter)
Sets a search filter, when ever the data store receives a
SearchEvent it will use this
search filter to filter the data list |
void |
updateRecord(int index,
T record)
updates a single record at a specific index in the current list and updates the data table
accordingly
|
void |
updateRecord(T record)
updates existing record from the current list and updates the data table accordingly
|
void |
updateRecords(Collection<T> records)
updates existing records from the current list and updates the data table accordingly
|
void |
updateRecords(int startIndex,
Collection<T> records)
updates records from the current list starting from a specific index and updates the data table
accordingly
|
public LocalListDataStore()
public void setData(List<T> data)
data - the new List of recordspublic SearchFilter<T> getSearchFilter()
SearchFilter if exists, otherwise return
nullpublic LocalListDataStore<T> setSearchFilter(SearchFilter<T> searchFilter)
SearchEvent it will use this
search filter to filter the data listsearchFilter - SearchFilterpublic LocalListDataStore<T> setAutoSort(boolean autoSort)
autoSort - if true the data store will automatically sort the data list list before
loading it into the data tablepublic LocalListDataStore<T> setAutoSortBy(String autoSortBy)
autoSortBy - String, the name of initial sort columnpublic LocalListDataStore<T> setAutoSortDirection(SortDirection autoSortDirection)
autoSortDirection - SortDirectionpublic HasPagination getPagination()
HasPagination component used in this data storepublic LocalListDataStore<T> setPagination(HasPagination pagination)
pagination - HasPaginationpublic RecordsSorter<T> getRecordsSorter()
RecordsSorter used in this data storepublic LocalListDataStore<T> setRecordsSorter(RecordsSorter<T> recordsSorter)
recordsSorter - RecordsSorterpublic LocalListDataStore<T> setRecordsSorter(RecordsSorter<T> recordsSorter, LocalListDataStore.SortFunction<T> sortFunction)
public void onDataChanged(StoreDataChangeListener<T> dataChangeListener)
DataChangedEvent eventsonDataChanged in interface DataStore<T>dataChangeListener - StoreDataChangeListenerpublic void removeDataChangeListener(StoreDataChangeListener<T> dataChangeListener)
removeDataChangeListener in interface DataStore<T>dataChangeListener - StoreDataChangeListenerpublic void handleEvent(TableEvent event)
SearchEvent
SortEvent
TablePageChangeEvent
handleEvent in interface TableEventListenerevent - the TableEvent being receivedpublic void load()
public void addRecord(T record)
record - T the new record being addedpublic void removeRecord(T record)
record - T the record being removedpublic void updateRecord(T record)
record - T the record being updatedpublic void updateRecord(int index,
T record)
record - T the record being updatedindex - the index of the record to be updatedpublic void updateRecords(Collection<T> records)
records - records to be updatedpublic void updateRecords(int startIndex,
Collection<T> records)
While updating the records, if the index is out of range then the process will stop.
records - records to be updatedpublic void addRecords(Collection<T> records)
records - Collection of records@Deprecated public void removeRecord(Collection<T> records)
removeRecords(java.util.Collection<T>)public void removeRecords(Collection<T> records)
records - Collection of recordspublic List<T> getRecords()
Copyright © 2019–2022 Dominokit. All rights reserved.