new Handler()

Description
This class exposes the main method used to manipulate table data, like filtering, sorting, or paginating. You can override instance's members to customize the behavior of your datatable. Handlers are called in this order: filter, sort, paginate, display. In case you are overriding *one* of those handlers, make sure that its return value is compatible with subsequent handlers. Otherwise, you'll require to override all of them.

Methods


filterHandler( data, filters, columns ) → {Promise.<(Array.<TRow>|*)>}

Description
Filter the provided rows, checking if at least a cell contains one of the specified filters. It supports promises. Defaults to Handler#defaultFilterHandler.
Parameters
Name Type Description
data Array.<TRow> | * The data to apply filter on. It is usually an array of rows, but it can be whatever you set in the Datatable#data property.
filters Array.<string> | string | undefined The strings to search in cells.
columns Array.<Column> The columns of the table.
Returns
The filtered data. It is usually an array of rows, but it can be whatever you like.

sortHandler( filteredData, sortColumn, sortDir ) → {Promise.<(Array.<TRow>|*)>}

Description
Sort the given rows depending on a specific column & sort order. It suports promises. Defaults to Handler#defaultSortHandler.
Parameters
Name Type Description
filteredData Array.<TRow> | * Data outputed from Handler#filterHandler. It is usually an array of rows, but it can be whatever you like.
sortColumn Column The column used for sorting.
sortDir 'asc' | 'desc' | null The direction of the sort.
Returns
The sorted rows. It is usually an array of rows, but it can be whatever you like.

paginateHandler( sortedData, perPage, pageNumber ) → {Promise.<(Array.<TRow>|*)>}

Description
Split the rows list to display the requested page index. It supports promises. Defaults to Handler#defaultPaginateHandler.
Parameters
Name Type Description
sortedData Array.<TRow> | * Data outputed from Handler#sortHandler. It is usually an array of rows, but it can be whatever you like.
perPage number The total number of items per page.
pageNumber number The index of the page to display.
Returns
The requested page's rows. It is usually an array of rows, but it can be whatever you like.

displayHandler( processSteps ) → {Promise.<DisplayHandlerResult>}

Description
Handler to post-process the paginated data, and determine which data to actually display. It supports promises. Defaults to Handler#defaultDisplayHandler.
Parameters
Name Type Description
processSteps object The result of each processing steps, stored in an object. Each step is the result of one of the processing function (Handler#filterHandler, Handler#sortHandler, Handler#paginateHandler), applied on the previous step.
Name Type Description
source Array.<TRow> | * The original Datatable#data property of the datatable.
filtered Array.<TRow> | * The return value of Handler#filterHandler.
sorted Array.<TRow> | * The return value of Handler#sortHandler.
paged Array.<TRow> | * The return value of Handler#paginateHandler.
Returns
Processed values to set on the datatable.

defaultFilterHandler( data, filters, columns ) → {Promise.<Array.<TRow>>}

Description
Filter the provided rows, checking if at least a cell contains one of the specified filters.
Parameters
Name Type Description
data Array.<TRow> The data to apply filter on.
filters Array.<string> | string | undefined The strings to search in cells.
columns Array.<Column> The columns of the table.
Returns
The filtered data rows.
Details

defaultSortHandler( filteredData, sortColumn, sortDir ) → {Promise.<Array.<TRow>>}

Description
Sort the given rows depending on a specific column & sort order.
Parameters
Name Type Description
filteredData Array.<TRow> Data outputed from Handler#filterHandler.
sortColumn Column The column used for sorting.
sortDir 'asc' | 'desc' | null The direction of the sort.
Returns
The sorted rows.
Details

defaultPaginateHandler( sortedData, perPage, pageNumber ) → {Promise.<Array.<TRow>>}

Description
Split the rows list to display the requested page index.
Parameters
Name Type Description
sortedData Array.<TRow> Data outputed from Handler#sortHandler.
perPage number The total number of items per page.
pageNumber number The index of the page to display.
Returns
The requested page's rows.
Details

defaultDisplayHandler( processSteps ) → {Promise.<DisplayHandlerResult>}

Description
Handler to post-process the paginated data, and determine which data to actually display.
Parameters
Name Type Description
processSteps object The result of each processing steps, stored in an object. Each step is the result of one of the processing function (Handler#filterHandler, Handler#sortHandler, Handler#paginateHandler), applied on the previous step.
Name Type Description
source Array.<TRow> | * The original Datatable#data property of the datatable.
filtered Array.<TRow> | * The return value of Handler#filterHandler.
sorted Array.<TRow> | * The return value of Handler#sortHandler.
paged Array.<TRow> | * The return value of Handler#paginateHandler.
Returns
Processed values to set on the datatable.
Details

rowMatches( row, filterString, columns ) → {boolean}

Description
Check if the provided row contains the filter string in *any* column.
Parameters
Name Type Description
row TRow The data row to search in.
filterString string The string to match in a column.
columns Array.<Column> The list of columns in the table.
Returns
`true` if any column contains the searched string.
Details