Documentation
Component Inputs
| Input | Type | Description |
|---|---|---|
| [settings] | Object | Table component configuration object, properties described below |
| [source] | Array|DataSource | Table data, either an array or DataSource object (LocalDataSource currently supported) |
Table Configuration
| Property | Type | Default | Description |
|---|---|---|---|
| Required Table Settings | |||
| columns | Object | n/a |
Table column settings, by default an empty object. Example format:
columns: {{ '{' }}
columnKey: {{ '{' }}
title: 'Some Title'
{{ '}' }}
{{ '}' }}
Please note, columnKey must be the same as a key in data array objects. |
| Column Settings | List of a column's settings | ||
| title | string | '' | Column title |
| class | string | '' | Column class |
| width | string | '' | Column width, example: '20px', '20%' |
| editable | boolean | true | Whether this column is editable or not |
| type | 'text'|'html'|'custom' | 'text' |
If type is text then cell value will be inserted as text. If type is html then cell value will be inserted as html. If type is custom the renderComponent property must be defined.
|
| renderComponent | any | null |
Custom component that will be responsible for rendering the cell content while in view mode. Type must be custom in order for this to work. You can see an example here |
| onComponentInitFunction | Function | null | Function which will be invoked after renderComponent instantiated and before ngOnInit hook. This function gets renderComponent instance in first param. |
| editor | Object | n/a | Editor attributes settings |
| editor.type | 'text' | 'textarea' | 'completer' | 'list' | 'checkbox' | 'text' | Editor used when new row is added or edited |
| editor.config | Object | n/a | Editor configuration settings. Mandatory only for editor types completer, list |
| editor.config.true | string | '' |
Only on checkbox type. Defines the value to assign when the checkbox is checked. This parameter is optional, if omitted, true will be used.
|
| editor.config.false | string | '' |
Only on checkbox type. Defines the value to assign when the checkbox is not checked. This parameter is optional, if omitted, false will be used.
|
| editor.config.list | Array | [ ] |
Only on list type. Example format:{{ '{' }} value: 'Element Value', title: 'Element Title' {{ '}' }}Html is supported if column type is 'html' |
| editor.config.completer | Object | n/a |
Only on completer type. Example format: Completer configuration settings |
| editor.config.completer.data | Array | [ ] |
Autocomplete list data source. Example format: {{ '{' }} id: 10, name: 'Nick', email: 'rey@karina.biz' {{ '}' }}
|
| editor.config.completer.searchFields | string | '' | Comma separated list of fields to search on. Fields may contain dots for nested attributes; if empty or null all data will be returned |
| editor.config.completer.titleField | string | '' | Name of the field to use as title for the list item |
| editor.config.completer.descriptionField | string | '' | Name of the field to use as description for the list item |
| filter | Object | n/a |
Column filter attributes settings. This object accepts the same properties as the editor object.The available types are: checkbox, select, completer.The checkbox type accepts one more optional property compared to the editor version: resetText: string.
It defines the text of the button to reset the checkbox selection.Click here to see an example on how to configure it. |
| valuePrepareFunction | Function | n/a |
Function run against a value before it gets inserted into a cell.
You can use it to modify how a value is displayed in the cell.
This function will be invoked with 2 parameters: cell, row |
| sort | boolean | true | Column sort settings, enable/disable. |
| sortDirection | 'asc'|'desc' | n/a |
Sort table by this column with this direction by default. Applied only when sort = true. Note: multiple sort option is not supported yet, so sortDirection can be applied to only one column per table. |
| compareFunction | Function | n/a | Function run against the values to sort the table |
| filter | boolean | true | Column filter settings, enable/disable |
| filterFunction | Function | n/a | Function run against the column value when filtering is happening |
| Other Table Settings | |||
| mode | 'external'|'inline' | 'inline' |
Determines how to react on action links (Add, Edit, Delete). 'external' - just trigger the events (LINK HERE). 'inline' - process internally, show forms/inputs/etc |
| hideHeader | 'boolean' | false | Set to true to not display the table header (which includes table column titles) |
| hideSubHeader | 'boolean' | false | Set to true to not display the table sub-header (which includes filters and global table actions (currently - Add action)) |
| noDataMessage | string | 'No data found' | Message shown when there is no data in the table |
| attr | Object | n/a | Table attributes settings |
| attr.id | string | '' | Table element id |
| attr.class | string | '' | Table element class |
| actions | Object | n/a | Settings for the table actions |
| actions.columnTitle | string | 'Actions' | Actions column title |
| actions.add | boolean | true | Show/not show Add button |
| actions.edit | boolean | true | Show/not show Edit button |
| actions.delete | boolean | true | Show/not show Delete button |
| actions.position | 'left'|'right' | 'left' | Choose actions column position |
| filter | Object | n/a | Settings for the table filter |
| filter.inputClass | string | '' | Filter input class |
| edit | Object | n/a | Edit action settings |
| edit.inputClass | string | '' | Editing form input class |
| edit.editButtonContent | string | 'Edit' | Edit row button content/title |
| edit.saveButtonContent | string | 'Update' | Update button content/title |
| edit.cancelButtonContent | string | 'Cancel' | Cancel button content/title |
| edit.confirmSave | boolean | false | Enable/disable (confirmEdit) event. If enabled data will be edited only if confirm.resolve() called. |
| add | Object | n/a | Add action settings |
| add.inputClass | string | '' | New row input class |
| add.addButtonContent | string | 'Add New' | Add New button content/title |
| add.createButtonContent | string | 'Create' | Create button content/title |
| add.cancelButtonContent | string | 'Cancel' | Cancel button content/title |
| add.confirmCreate | boolean | false | Enable/disable (confirmCreate) event. If enabled data will be added only if confirm.resolve() called. |
| delete | Object | n/a | Delete action settings |
| delete.deleteButtonContent | string | 'Delete' | Delete row input class |
| delete.confirmDelete | boolean | false | Enable/disable (confirmDelete) event. If enabled data will be deleted only if confirm.resolve() called. |
| pager | Object | n/a | Pager settings |
| pager.display | boolean | true | Whether to display the pager or not |
| pager.perPage | number | 10 | Rows per page |
| rowClassFunction | Function | row | Handle css class for each row in the table |
Component Outputs/Events
| Event | Arguments | Description |
|---|---|---|
| (rowSelect) |
event: Object, consist of:
|
Triggered once a row is selected (either clicked or selected automatically (after page is changed, after some row is deleted, etc)). |
| (userRowSelect) |
event: Object, consist of:
|
Triggered only on a user click event. |
| (mouseover) |
event: Object, consist of:
|
Triggered only on a user mouseover event. |
| (create) |
event: Object, consist of:
|
Triggered once a Create button clicked. Triggered only if table mode = external. |
| (createConfirm) |
event: Object, consist of:
|
Triggered once a Create button clicked. Triggered only if table confirmCreate = true and mode = inline. Allows you to confirm changes before they are applied to the table data source. |
| (edit) |
event: Object, consist of:
|
Triggered once an Edit button clicked on a row. Triggered only if table mode = external. |
| (editConfirm) |
event: Object, consist of:
|
Triggered once a Save button clicked. Triggered only if table confirmSave = true and mode = inline. Allows you to confirm changes before they are applied to the table data source. |
| (delete) |
event: Object, consist of:
|
Triggered once a Delete button clicked on a row. Triggered only if table mode = external. |
| (deleteConfirm) |
event: Object, consist of:
|
Triggered once a Delete button clicked. Triggered only if table confirmDelete = true and mode = inline. Allows you to confirm changes before they are applied to the table data source. |
Data Source Methods
| Method | Arguments | Description |
|---|---|---|
| load |
| Reload table with new data. For example if some data has received from the server. |
| prepend |
| Add a new element to the beginning of the table. |
| append |
| Add a new element to the end of the table. This also will switch current page to the last one. |
| add |
| Add a new element to the table. |
| remove |
| Remove the element from the table. |
| update |
| Update the element in the table. |
| find |
| Find the element in the table. |
| getElements | n/a | Get elements for current sort, filter and page. |
| getFilteredAndSorted | n/a | Get sorted, filtered and not paginated elements. |
| getAll | n/a | Get all data source elements. |
| setSort |
|
Set table sorts, example: this.source.setSort([{{ '{' }} field: 'id', direction: 'asc' {{ '}' }}]);
|
| setFilter |
|
Set table filters, example: this.source.setFilter([{{ '{' }} field: 'id', search: 'foobar' {{ '}' }}, {{ '{' }} field: 'name', search: 'foobar' {{ '}' }}]);
|
| addFilter |
|
Set table filter for one column, example: this.source.addFilter({{ '{' }} field: 'id', search: 'foobar' {{ '}' }});
|
| setPaging |
| Set table pagination settings |
| setPage |
| Set table page |
| reset |
| Set data source to first page with empty filter and empty sort. |
| refresh | n/a | Refresh data in the data source. In most cases you won't need this method. |
| count | n/a | Return count of element in the data source. |
| empty | n/a | Empty the data source. |