SelectableTableDirectives
This library was generated with Angular CLI version 10.1.6.
Description
Angular directives for develop a selectable table.
Instalation
Use the package manager npm to install ad-selectable-table-directives.
npm install ad-selectable-table-directives
Demo
SelectableTableDirectivesDemo
Usage
Module
import SelectableTableModule from 'node-modules/ad-selectable-table-directives';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
SelectableTableModule.forRoot([{
TABLE_ID: "table1",
CELL_SELECTED_CLASSES: ['selected'],
CELL_SELECTABLE_CLASSES: ['selectable'],
ROWCELL_SELECTABLE_CLASSES: ['rowSelectable'],
ROWCELL_SELECTED_CLASSES: ['rowSelected'],
ROWCELL_PARCIAL_SELECTED_CLASSES: ['rowParcialSelected'],
COLUMNCELL_SELECTABLE_CLASSES: ['columnSelectable'],
COLUMNCELL_SELECTED_CLASSES: ['columnSelected'],
COLUMNCELL_PARCIAL_SELECTED_CLASSES: ['columnParcialSelected'],
},
{
TABLE_ID: "",
CELL_SELECTED_CLASSES: ['selected'],
CELL_SELECTABLE_CLASSES: ['selectable'],
ROWCELL_SELECTABLE_CLASSES: ['rowSelectable'],
ROWCELL_SELECTED_CLASSES: ['rowSelected'],
ROWCELL_PARCIAL_SELECTED_CLASSES: ['rowParcialSelected'],
COLUMNCELL_SELECTABLE_CLASSES: ['columnSelectable'],
COLUMNCELL_SELECTED_CLASSES: ['columnSelected'],
COLUMNCELL_PARCIAL_SELECTED_CLASSES: ['columnParcialSelected'],
}
])
],
providers: [],
bootstrap: [AppComponent]
})
NOTE The config are optional, and you can set a default config via {TABLE_ID:""} or {TABLE_ID:"default"}
REMEMBER Add classes in configuration to styles.scss or corresponding component styles.
any.component.html
<table SelectableTable class="table">
<thead>
<tr SelectableHeader>
<th></th>
<th SelectableColumnCell *ngFor="let col of columns" scope="col">{{col}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of rows" SelectableRow>
<th scope="row" SelectableRowCell>{{row}}</th>
<td *ngFor="let col of columns" SelectableCell >C:{{col}}R:{{row}}</td>
</tr>
</tbody>
</table>
any.component.ts
export class SelectableTableDemoComponent {
title = 'SelectableTableDemo';
columns: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
rows: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
constructor() {
}
}
IMPORTANT This is the most basic example, if you are not added classes to tableConfig it will not show nothing.
NOTE For more info see the Documentation below or see this example on GitHub:
DEMO
Documentation
- ##### GETTERS
``` typescript
SelectedCellsObservable :Observable<SelectableCell[]>;
SelectedRowCellsObservable :Observable<SelectableRowCell[]>;
SelectedColumnCellsObservable :Observable<SelectableColumnCell[]>;
SelectableTableApi :SelectableTableAPI;
```
- ##### INPUTS
```typescript
@Input() SelectableTableID:ID//Identifier for the table, if not provide it take the default config, otherwise take the config with the same TABLE_ID
```
- #### OUTPUTS
```typescript
@Output() cellSelected: EventEmitter<SelectableCellValue>;
@Output() cellRemoved: EventEmitter<SelectableCellValue>;
@Output() rowSelected: EventEmitter<SelectableRowCell>;
@Output() rowRemoved: EventEmitter<SelectableRowCell>;
@Output() columnSelected: EventEmitter<SelectableColumnCell>;
@Output() columnRemoved: EventEmitter<SelectableColumnCell>;
@Output() selectionClear: EventEmitter<void>;
@Output() tableReady : EventEmitter<SelectableTableAPI>;//Return the tableAPI object
```
Copyright and license
Code and documentation copyright 2020 Ángel Díez. Code released under the MIT license. Docs released under Creative Commons.
Contribute
If you want contribute for improve this project and the author, you can make donations in the next link via (paypal.me/angeldiez11)