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

PanemuTableController

Generic types:T

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[]
showSettingDialog
Function

Show dialog to customize column position, visibility and stickiness

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

Transpose selected row and displayed in a dialog. While the dialog is shown user can select a different row in the table.

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 editingController

No documentation has been provided.

Presentation
get editingController(): PanemuTableEditingController<T> | undefined;
Type

PanemuTableEditingController<T> | undefined

set editingController

No documentation has been provided.

Presentation
set editingController(ec: PanemuTableEditingController<T> | undefined);
Type

PanemuTableEditingController<T> | undefined

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 mode

No documentation has been provided.

Presentation
get mode(): Signal<TABLE_MODE>;
Type

Signal<TABLE_MODE>

get selectedRowSignal

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

Presentation
get selectedRowSignal(): Signal<T | null>;
Type

Signal<T | null>

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

deleteSelectedRow()

In browse mode, it will execute PanemuTableEditingController.deleteData() method. In insert mode, it will just remove the inserted row from the table.

Presentation
deleteSelectedRow(): 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

edit()

Change table mode to edit. It will throw an error if this controller doesn't have editingController.

Presentation
edit(): void;
Returns

void

expand()

Expand cell. Only works if 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

exportToCsv()

It calls getCsvData method and instructs browser to download the data as csv file.

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

provide a way to exclude header or RowGroup rows.

Returns

void

getAllData()

Get data being displayed in table including RowGroup, RowGroupFooter and ExpansionRow. 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.

Take a look at exportToCsv function as well.

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, RowGroupFooter and ExpansionRow.

To get all data from table including of type RowGroup, RowGroupFooter 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

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

insert()

Change table mode to insert and insert new row at the first index. It will throw an error if this controller doesn't have editingController.

Presentation
insert(): void;
Returns

void

markForCheck()

Call angular ChangeDetectorRef.markForCheck

Presentation
markForCheck(): void;
Returns

void

readState()

Read state.

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

Observable<TableState | null>

relayout()

Called by setting component to repaint table header

Presentation
relayout(): void;
Returns

void

reloadCurrentPage()

Reload data without resetting pagination start index. It will cancel edit or insert mode and back to browse mode.

Presentation
reloadCurrentPage(): void;
Returns

void

reloadData()

Reload data but reset the pagination start index to 0 before hand. It will cancel edit or insert mode and back to browse mode.

Presentation
reloadData(): void;
Returns

void

async

save()

Save changed rows. This method does the followings:

  1. Call editingController._getChangedData
  2. Call editingController._validate. It executes validation on cell basis.
  3. Call editingController.canSave. It is a hook to allow user to cancel the save operation or doing row level validation.
  4. Call editingController.saveData. It saves the data to server.
  5. Call editingController.afterSuccessfulSave. It is a hook to do something after the data is saved.
  6. Change mode to browse.
Presentation
async save(): Promise<void>;
Returns

Promise<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.saveState is defined. The key 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