Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultHandler<TRow>

This handler is an implementation of IHandler, configured to manipulate an array of rows as input. 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.

tutorial

Ajax table (with handler customization)

Type parameters

  • TRow: __type

Hierarchy

  • DefaultHandler

Implements

  • IHandler<TRow, TRow[], TRow[], TRow[], TRow[]>

Index

Methods

displayHandler

filterHandler

  • filterHandler(data: TRow[], filters: string[] | string | undefined, columns: Array<Column<TRow>>): TMaybePromise<TRow[]>
  • Filter the provided rows, checking if at least a cell contains one of the specified filters.

    Parameters

    • data: TRow[]

      The data to apply filter on.

    • filters: string[] | string | undefined

      The strings to search in cells.

    • columns: Array<Column<TRow>>

      The columns of the table.

    Returns TMaybePromise<TRow[]>

    the filtered data rows.

paginateHandler

  • paginateHandler(sortedData: TRow[], perPage: number | null, pageNumber: number): TMaybePromise<TRow[]>
  • Split the rows list to display the requested page index.

    Parameters

    • sortedData: TRow[]

      Data outputed from [[Handler.sortHandler]].

    • perPage: number | null

      The total number of items per page.

    • pageNumber: number

      The index of the page to display.

    Returns TMaybePromise<TRow[]>

    the requested page's rows.

rowMatches

  • rowMatches(row: TRow, filterString: string, columns: Array<Column<TRow>>): boolean
  • Check if the provided row contains the filter string in any column.

    Parameters

    • row: TRow

      The data row to search in.

    • filterString: string

      The string to match in a column.

    • columns: Array<Column<TRow>>

      The list of columns in the table.

    Returns boolean

    true if any column contains the searched string.

sortHandler

  • Sort the given rows depending on a specific column & sort order.

    Parameters

    • filteredData: TRow[]

      Data outputed from [[Handler.filterHandler]].

    • sortColumn: Column<TRow> | null

      The column used for sorting.

    • sortDir: ESortDir | null

      The direction of the sort.

    Returns TMaybePromise<TRow[]>

    the sorted rows.

Generated using TypeDoc