You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 25, 2021. It is now read-only.
##### 2. Include `<data-table>` and `<data-table-column>` into your component's template.
68
+
```HTML
69
+
<!-- my.component.template -->
70
+
<div>
71
+
...
72
+
<data-tableid="my-table"
73
+
...
74
+
[title]="'Employees'"
75
+
[items]="items"
76
+
[itemCount]="itemCount"
77
+
...
78
+
>
79
+
<data-table-column
80
+
[property]="'name'"
81
+
[header]="'name'"
82
+
... >
83
+
</data-table-column>
84
+
<data-table-column
85
+
...
86
+
</data-table-column>
87
+
</data-table>
88
+
...
89
+
</div>
90
+
```
91
+
92
+
## API
93
+
94
+
### data-table
95
+
*`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.
96
+
*`showTitle` (`boolean` | default: `true`): if `false`, 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.
97
+
*`items` (`JsonObject[]` | default: `[]`) table data to show.
*`header` (`boolean` | default: `true`) show/hide the table header sub-component - this holds the table name and two buttons (_reload table_ and _column selector_).
100
+
*`pagination` (`boolean` | default: ) enable pagination. If `true`, pagination controls are shown at the bottom of the table.
101
+
*`indexColumn` (`boolean` | default: `true`) when `true` the table shows a 0-indexed column.
102
+
*`indexColumnHeader` (`string` | default: `''`) text shown as column header for the index column.
103
+
*`selectColumn` (`boolean` | default: `false`) when `true` the table shows a checkbox column for selecting specific row.
104
+
*`multiSelect` (`boolean` | default: `false`) allows multi-row selection, showing a checkbox at select's column header.
105
+
*`labels` (`DataTableTranslations` | default: `defaultTranslations`) interface holding all needed labels. You can pass a subset of the labels. The missing labels will be defaulted.
106
+
*`expandableRow` (`boolean` | default: `false`) when `true` each row will have a collapsible content.
107
+
*`selectOnRowClick` (`boolean` | default: `false`) when `true` each row is selectable via a single-click.
108
+
*`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.
109
+
*`autoReload` (`boolean` | default: `false`) when `true`, the `reload` function gets invoked and init time (`ngOnInit`).
110
+
*`rowColors` (`function(): 'color` | default: `null`) custom function that must return a _CSS color_ that will be applied to the entire row.
111
+
*`rowTooltip` (`function` | default: `null`) custom function to show a title tooltip when hovering the row.
112
+
*`showReloading` (`boolean` | default: `true`) when `true` an overlay with a gear icon is shown on top of the table while it's reloading.
113
+
*`noDataMessage` (`string` | default: `''`) message displayed when no item are displayed. If it's empty nothing is shown.
*`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.
116
+
*`page` (`number` | default: `0`) page to load, valid only if pagination is enabled.
117
+
*`limit` (`number` | default: `10`) number of items per page, valid only pagination is enabled. If `limit` value is not a valid (not contained into `pageLimits` array) it will be defaulted to `pageLimits`'s first value.
118
+
*`sortBy` (`string` | default: `''`) column table is sorted by.
119
+
*`sortAsc` (`boolean` | default: `true`) valid only if `sortBy` is not defaulted. Defines the sorting order. If `true` sort is ascending, descending otherwise.
120
+
121
+
### data-table-column
122
+
*`property` (`string` | default: _no default_) item's `JSONObject` key used to retrieve the row cell content.
*`sortable` (`boolean` | default: `false`) marks the columns as sortable.
125
+
*`resizable` (`boolean` | default: `false`) marks the columns as resizable.
126
+
*`visible` (`boolean` | default: `true`) marks the columns visible.
127
+
*`width` (`number | string` | default: `''`) defines the column width. It can be a string like `2rem` or a number. If it's a number, it will be considered as pixels.
128
+
129
+
### Custom column templates
130
+
data-column's content and header are not restricted to be text only - they can hold complex content too. In order to do that developers can use two references: `#dataTableHeader` and `#dataTableCell`.
As it can be seen from the above snippet, the `dataTableHeader` and `dataTableCell` are targeting two `<ng-template>`s nodes which will be used respectively as column header and cell content. In both cases `item` refers to the whole row item, so developers can use whatever they may need.
149
+
150
+
## Demo app
151
+
Clone this repository, run `npm install` and `ng serve`, then navigate to `http:localhost:4200` where you can access to the demo application sporting a few demos with code viewer and docs.
For creating a distributable version, run `npm run build`, then run `npm run pack-lib`. This will create a tar.gz file containing the library, which can be installed within your projects. The packager system is based on [Angular Library Starter](https://github.com/robisim74/angular-library-starter/)
0 commit comments