@foton_informatica/ftn-data-table
v1.6.1
Published
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.4.
Downloads
3
Readme
FtnDataTable
This project was generated with Angular CLI version 1.7.4.
##Dependencies
npm install [email protected] [email protected]
... then you need to include the CSS bundles into .angular-cli.json file as show below.
{
"apps": [
{
"root": "src",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/font-awesome/css/font-awesome.css",
"styles.css"
]
}
]
}
##Installing
npm i @foton_informatica/ftn-data-table
Usage
1.Import Datatable module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { DataTableModule } from '@foton_informatica/ftnDataTable';
@NgModule({
imports: [
...
DataTableModule.forRoot()
...
],
bootstrap: [AppComponent]
})
export class AppModule { }
2. Include <app-ftn-data-table>
and <data-table-column>
into your component's template.
<!-- my.component.template -->
<div>
...
<app-ftn-data-table id="my-table"
...
[title]="'Employees'"
[items]="items"
[itemCount]="itemCount"
...
>
<data-table-column
[property]="'name'"
[header]="'name'"
... >
</data-table-column>
<data-table-column
...
</data-table-column>
</app-ftn-data-table>
...
</div>
API
The component is highly configurable and customizable through many Inputs and Events.
app-ftn-data-table
title
(string
| default:''
) table's name - it's highly recommend it's set for accessibility reasons as this will provide a better experience when interacting with the component, especially through a SR.showTitle
(boolean
| default:true
): iffalse
, the title is not shown into the component. Useful when want the header component visible (with its Reload and Coulumn Selector buttons), but not the title.className
(string
| default:''
) setting class for datatable (Bootstrap Class DataTable).items
(JsonObject[]
| default:[]
) table data to show.itemCount
(number
| default:0
) items's count.showButtonReloadItems
(boolean
| default:false
) show/hide button reload datatable items.showButtonChooseColumns
(boolean
| default:false
) show/hide button for choose columns.header
(boolean
| default:true
) show/hide the table header sub-component - this holds the table name and two buttons (reload table and column selector).pagination
(boolean
| default: ) enable pagination. Iftrue
, pagination controls are shown at the bottom of the table.indexColumn
(boolean
| default:true
) whentrue
the table shows a 0-indexed column.indexColumnHeader
(string
| default:''
) text shown as column header for the index column.selectColumn
(boolean
| default:false
) whentrue
the table shows a checkbox column for selecting specific row.multiSelect
(boolean
| default:false
) allows multi-row selection, showing a checkbox at select's column header.labels
(DataTableTranslations
| default:defaultTranslations
) interface holding all needed labels. You can pass a subset of the labels. The missing labels will be defaulted.expandableRow
(boolean
| default:false
) whentrue
each row will have a collapsible content.selectOnRowClick
(boolean
| default:false
) whentrue
each row is selectable via a single-click.reload
(function(): void
| default:null
) function that is invoked when the table needs to re-render its data. Note: most of the times this is the place where the developer connects to a server in order to pull down the item set.autoReload
(boolean
| default:false
) whentrue
, thereload
function gets invoked and init time (ngOnInit
).rowColors
(function(): 'color
| default:null
) custom function that must return a CSS color that will be applied to the entire row.rowTooltip
(function
| default:null
) custom function to show a title tooltip when hovering the row.showReloading
(boolean
| default:true
) whentrue
an overlay with a gear icon is shown on top of the table while it's reloading.noDataMessage
(string
| default:''
) message displayed when no item are displayed. If it's empty nothing is shown.pageLimits
(number[]
| default:[10, 25, 50, 100, 250]
) items per page selector options.primaryColumn
(string
| default: first data column) it identifies which columns has be marked as primary. This is an important aspect from an accessibility and SR perspective. If not given, the first column will be the primary column.page
(number
| default:0
) page to load, valid only if pagination is enabled.limit
(number
| default:10
) number of items per page, valid only pagination is enabled. Iflimit
value is not a valid (not contained intopageLimits
array) it will be defaulted topageLimits
's first value.sortBy
(string
| default:''
) column table is sorted by.sortAsc
(boolean
| default:true
) valid only ifsortBy
is not defaulted. Defines the sorting order. Iftrue
sort is ascending, descending otherwise.
data-table-column
property
(string
| default: no default) item'sJSONObject
key used to retrieve the row cell content.header
(string
| default: no default) column header text.sortable
(boolean
| default:false
) marks the columns as sortable.resizable
(boolean
| default:false
) marks the columns as resizable.visible
(boolean
| default:true
) marks the columns visible.width
(number | string
| default:''
) defines the column width. It can be a string like2rem
or a number. If it's a number, it will be considered as pixels.
Custom column templates
data-column's content and header are not restricted to be text only. They can hold more complex components. In order to do that developers can use two references: #dataTableHeader
and #dataTableCell
.
Usage and sample
<app-ftn-data-table>
...
<data-table-column
header="Actions">
<ng-template #dataTableHeader let-item="item">
<i>Actions</i>
</ng-template>
<ng-template #dataTableCell let-item="item">
<button (click)="carClicked(item)" class="btn btn-sm btn-default">Buy</button>
</ng-template>
</data-table-column>
...
</app-ftn-data-table>