Getting Started
Usages
Columns
API References
ngx-panemu-table / Class

PanemuTableController

Generic types:T
Implements:PanemuPaginationController

This class provide a way to interact with PanemuTableComponent. It requires columns information and a way to get data.

Properties

NameTypeDescription
criteria
TableCriteria[]
groupByColumns
GroupBy[]
refreshTable
Function

Force refresh the table.

relayout
Function

Called by setting component to repaint table header

sortedColumn
{ [key: string]: "asc" | "desc"; }
tableOptions
TableOptions<T>

Accessors

get afterReloadEvent

Observable to listen to after reload event. This is only for table controller. It will not fire for RowGroup expand action because RowGroup has its own controller instance.

Presentation
get afterReloadEvent(): Observable<TableData<T> | null>;
Type

Observable<TableData<T> | null>

get beforeReloadEvent

This observable fire just before loading a data. This is only for table controller. It will not fire for RowGroup expand action because RowGroup has its own controller instance.

Presentation
get beforeReloadEvent(): Observable<number>;
Type

Observable<number>

get loading

Get loading observable. Loading status is true when data is being retrieved from datasource.

Presentation
get loading(): Observable<boolean>;
Type

Observable<boolean>

get maxRows

Get max rows from connected PanemuPaginationComponent.

To change default max rows for all tables across application, create a service extending PanemuTableService and override PanemuTableService.getPaginationMaxRows()

Presentation
get maxRows(): number;
Type

number

set maxRows

Set max rows to display in table. Only usable if there is PanemuPaginationComponent using this controller. Otherwise all data from datasource is displayed at once.

To change default max rows for all tables across application, create a service extending PanemuTableService and override PanemuTableService.getPaginationMaxRows().

The value is limited by PanemuTableService.getPaginationMaxRowsLimit().

Presentation
set maxRows(val: number);
Type

number

get startIndex

Get start index from connected PanemuPaginationComponent. First index is 0.

Presentation
get startIndex(): number;
Type

number

set startIndex

Set start index. Only usable if there is PanemuPaginationComponent using this controller.

Presentation
set startIndex(val: number);
Type

number

Static Methods

static

create()

Create controller with pagination, sorting, filtering and grouping handled by supplied PanemuTableDataSource.

Presentation
static create(columns: ColumnDefinition<T>, datasource: PanemuTableDataSource<T>, tableOptions?: Partial<TableOptions<T>> | undefined): PanemuTableController<T>;
Parameters
NameTypeDescription
columns
ColumnDefinition<T>
datasource
PanemuTableDataSource<T>
tableOptions
Partial<TableOptions<T>> | undefined
Returns

PanemuTableController<T>

static

createWithCustomDataSource()

Create controller with pagination, sorting, filtering and grouping handled by custom datasource. It provide a way to specify custom logic for pagination, sorting, filtering and grouping in server side.

Presentation
static createWithCustomDataSource(columns: ColumnDefinition<T>, retrieveDataFunction: RetrieveDataFunction<T>, tableOptions?: Partial<TableOptions<T>> | undefined): PanemuTableController<T>;
Parameters
NameTypeDescription
columns
ColumnDefinition<T>
retrieveDataFunction
RetrieveDataFunction<T>
tableOptions
Partial<TableOptions<T>> | undefined
Returns

PanemuTableController<T>

Methods

clearSelection()

Clear row selection

Presentation
clearSelection(): void;
Returns

void

deleteState()

Delete table state. By default, it reload the window after it.

Presentation
deleteState(reloadAfterDelete: boolean = true): void;
Parameters
NameTypeDescription
reloadAfterDelete
boolean
Returns

void

expand()

Expand cell. Only works of the column BaseColumn.expansion is defined.

Presentation
expand(row: T, column: BaseColumn<T>, expanded?: WritableSignal<boolean> | undefined): void;
Parameters
NameTypeDescription
row
T
column
BaseColumn<T>
expanded
WritableSignal<boolean> | undefined

a signal to listen to expand/collapse state.

Returns

void

getAllData()

Get data being displayed in table including ExpansionRow and RowGroup. If a RowGroup is collapsed, its children are not included because they aren't visible in the table.

Presentation
getAllData(): (T | RowGroup | RowGroupFooter | ExpansionRow<T>)[];
Returns

(T | RowGroup | RowGroupFooter | ExpansionRow<T>)[]

getAllDataAsSignal()

Get data being displayed in table as signal. See also getAllData method.

Presentation
getAllDataAsSignal(): WritableSignal<(T | RowGroup | RowGroupFooter | ExpansionRow<T>)[]>;
Returns

WritableSignal<(T | RowGroup | RowGroupFooter | ExpansionRow<T>)[]>

getCsvData()

Get data as comma separated string. By default it includes the header and RowGroups.

Presentation
getCsvData(options?: { includeHeader?: boolean | undefined; includeRowGroup?: boolean | undefined; } | undefined): string;
Parameters
NameTypeDescription
options
{ includeHeader?: boolean | undefined; includeRowGroup?: boolean | undefined; } | undefined

provide a way to exclude header or RowGroup rows.

Returns

string

getData()

Get data being displayed in table. It only returns regular row data. It excludes RowGroup and ExpansionRow. It doesn't returns all data in datasource.

To get all date from table including of type RowGroup and ExpansionRow see getAllData method.

Presentation
getData(): T[];
Returns

T[]

getSelectedRow()

Get selected row. A row is selected if user click it. RowGroup cannot be selected.

Presentation
getSelectedRow(): T | null;
Returns

T | null

getSelectedRowSignal()

Get selected row as signal. A row is selected if user click it. RowGroup cannot be selected.

Presentation
getSelectedRowSignal(): Signal<T | null>;
Returns

Signal<T | null>

initPaginationComponent()

Connect pagination component with the controller. It tells the controller that pagination should be used. If there is no pagination component calling this method, the controller will set its maxRows to 0 which means the datasource should return all data.

The controller will also tell the pagination about pagination information after each reload.

Presentation
initPaginationComponent(refreshAction: RefreshPagination): void;
Parameters
NameTypeDescription
refreshAction
RefreshPagination

callback function called by the controller so that the pagination

Returns

void

readState()

Read state.

Presentation
readState(): Observable<TableState | null>;
Returns

Observable<TableState | null>

reloadCurrentPage()

Reload data without resetting pagination start index.

Presentation
reloadCurrentPage(): void;
Returns

void

reloadData()

Reload data but reset the pagination start index to 0 before hand.

Presentation
reloadData(): void;
Returns

void

saveState()

Save table states. The states are:

  1. Column visibility, order and stickiness
  2. Sorting
  3. Pagination
  4. Filtering
  5. Grouping

Saving state only works if TableOptions.stateKey is defined. It has to be unique app-wide. The state is stored in local storage. To save in db server, override PanemuTableService.saveTableState().

Presentation
saveState(): void;
Returns

void

selectFirst()

Select the first data row (not RowGroup nor ExpansionRow). If the table is groupped and none of the group is expanded, this function will always return false because none will be selected.

Presentation
selectFirst(): boolean;
Returns

boolean

selectRow()

Select a row in the table by row index or row object. RowGroup can't be selected.

Presentation
selectRow(rowOrIndex: number | T): boolean;
Parameters
NameTypeDescription
rowOrIndex
number | T

row index or row object

Returns

boolean