0.0.37 • Published 1 year ago

@agentsmith.bgd/dynamic-table-lib v0.0.37

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

DynamicTableLib

Dynamic table component

Attributes

AttributeTypeDescription
loading=falsebooleanIf data are currently loading. Shows spinner if true and dim the table
striped=falsebooleanAdd table-stripped class
bordered=falsebooleanAdd table-bordered class
hovered=falsebooleanAdd table-hovered class
enableSearch=falsebooleanEnables search field
rowCounter=falsebooleanAdd first column as row counter
enableLog=falsebooleanEnable console logger (developer logs)
perPage=0numberOffset for table pagination
page=0numberCurrent page (active page)
totalItems=0numberTotal items in page
tableHeadStorageKeyName=nullstringTotal items in page
tableStyle="""" or "table-light" or "table-dark"If key name is set, column chooser is enabled and new layout will be saved to localStorage
headStyle="table-default""table-default" or "table-primary" or "table-secondary" or "table-success" or "table-danger" or "table-warning" or "table-info" or "table-light" or "table-dark"Style of the table header
paginationAlignment="""" or "justify-content-center" or "justify-content-end"Aligment of pagination component left(default), center or right
perPageValues!:=[10, 20, 50, 100]number[]Displays dropdown with page offset chooser
headerActions!:=[]IActionButton[]CTA buttons in table header
rowActions!:=[]IActionButton[]CTA buttons in each table row
tableHead!:=nullITableHead[]Setup of the table. Columns are created, and key is used to access data values
tableData!:=nullRecord<string, never>[]Table data. Array of objects where key coresponds to tableHead key

Events

EventDescription
pageChange(page):EventEmitter<number>Dispatch when we click on pagination buttons and emits target page
filterChanged(IFilter):EventEmitter<IFilter>Dispatch when some display or filtering option is changed
editRow(Record):EventEmitter<Record<string, never>>Dispatch when some row action button is clicked
sliderClicked(Record):EventEmitter<Record<string, never>>Dispatch when some slider is clicked in row
headerActionClicked(actionname):EventEmitter<string>Dispatch when header action is clicked emitting action name
rowActionClicked({ action: actionName; value: rowData }):EventEmitter<{ action: string; value: any }>Dispatch when row action is clicked emitting action name and row data

Installation

Install dynamictable-lib from npm

npm i @agentsmith.bgd/dynamictable-lib

Add package to NgModule imports:

import { DynamicTableLibModule } from '@agentsmith.bgd/dynamictable-lib';

@NgModule({
	...
	imports: [DynamicTableLibModule, ...],
	...
})

Add component to your page

rowActions: IActionButton[] = [
{ actionName: 'edit', btnColor: 'btn-primary', faIcon: 'fa-edit' },
{ actionName: 'options', btnColor: 'btn-success', faIcon: 'fa-cogs' },
{ actionName: 'delete', btnColor: 'btn-danger', faIcon: 'fa-times' },
];
tableHead: ITableHead[] = [
{ key: 'id', label: 'ID', mandatory: true },
{ key: 'name', label: 'Name' },
{ key: 'email', label: 'Email' },
{ key: 'gender', label: 'Gender' },
{ key: 'company', label: 'Company' },
{ key: 'age', label: 'Age', hidden: true },
];
tabledata = [
{
name: 'Ethel Price',
email: 'Ethel Price@company.com',
gender: 'female',
company: 'Johnson, Johnson and Partners, LLC CMP DDC',
age: 22,
},
{
name: 'Claudine Neal',
email: 'Claudine Neal@company.com',
gender: 'female',
company: 'Sealoud',
age: 55,
}
<as-dynamic-table
  (pageChange)="pageChange($event)"
  (filterParamsChanged)="sortChanged($event)"
  [bordered]="true"
  [rowCounter]="true"
  [headStyle]="'table-success'"
  [headerActions]="headerActions"
  [hovered]="true"
  [page]="0"
  [perPage]="15"
  [rowActions]="rowActions"
  [striped]="false"
  [tableData]="tableData"
  [tableHeadStorageKeyName]="'someKey'"
  [tableHead]="tableHead"
  [totalItems]="totalItem"
></as-dynamic-table>

Compatibility

There is only one dependency: Angular > 12.x.x

0.0.37

1 year ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.8

2 years ago

0.0.2

2 years ago

0.0.5

2 years ago

0.0.3

2 years ago