TCB Base Table Component
The CmsBaseTableComponent is a reusable table component for Angular applications. It provides rich features like dynamic data rendering, customizable templates, row and cell actions, selection management, and event emitters for handling interactions like sorting, row selection, and custom actions.
How to use the component in your app :
Import the component :
import {CmsBaseTableComponent} from '@tradinos/cms-frontend-entity';The selector for component, like it :
<lib-cms-base-table></lib-cms-base-table>Features
Dynamic Data Rendering: Displays a list of data (
datainput) in a customizable table layout.Customizable Templates: Supports injecting custom templates for cells, headers, and empty states.
Row and Cell Actions: Allows actions to be performed at both the row and cell levels.
Selection Management: Enables row selection with support for multi-select and "select all."
Sorting: Emits sorting events for server-side or client-side sorting.
Event Emitters: Provides hooks to handle user interactions like selection, sorting, and actions.
Visibility Control: Supports toggling the visibility of actions dynamically.
Inputs
Input
Type
Description
Required
Default
data
T[]
The data array to display in the table.
Yes
[]
templates
{ [key: string]: TemplateRef<any> }
A set of custom templates for rendering specific parts of the table.
No
{}
tableConfiguration
BaseTableConfiguration<T>
Yes
-
actionsVisibility
boolean
Controls the visibility of actions in the table.
No
true
selection
T[] | null
Tracks the currently selected rows.
Yes
null
emptyDataTemplate
TemplateRef<any>
Custom template to display when the data array is empty.
No
-
Outputs
Output
Type
Description
selectAllChange
EventEmitter<TableSelectAllChangeEvent>
Emits when the "select all" checkbox is toggled.
selectionChange
EventEmitter<T[]>
Emits the current selection whenever rows are selected or deselected.
sortFunction
EventEmitter<SortEvent>
Emits a sorting event containing the column and direction.
cellAction
EventEmitter<{ key: string; item: T }>
Emits when a cell-specific action is triggered.
rowAction
EventEmitter<{ key: string; item: T }>
Emits when a row-specific action (e.g., view, delete) is triggered.
For example
Methods
visibleActionsCount(actions: BaseTableColumnAction[]): number
Description: Counts the number of visible actions for a given row or cell.
Logic:
Filters out actions where
visibleisfalseor thevisibleFnfunction evaluates tofalse.Returns the count of visible actions.
Use Case: Dynamically determine if action buttons should be displayed or hidden.
Last updated