Skip to content
Snippets Groups Projects
Commit 8e696c7b authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon: Committed by Reiter, Christoph
Browse files

Add placeholder for columns before table init

parent 1319701c
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
- example `<vpu-data-table-view paging></vpu-data-table-view>` - example `<vpu-data-table-view paging></vpu-data-table-view>`
- `searching` (optional, required if a search box is desired) - `searching` (optional, required if a search box is desired)
- example `<vpu-data-table-view searching></vpu-data-table-view>` - example `<vpu-data-table-view searching></vpu-data-table-view>`
- `columns.count` (optional, default: 1): add placeholder columns before first table setup
- example `<vpu-data-table-view column-count="7"></vpu-data-table-view>`
# Local development # Local development
```bash ```bash
......
...@@ -28,6 +28,7 @@ class DataTableView extends LitElement { ...@@ -28,6 +28,7 @@ class DataTableView extends LitElement {
this.columns = [{title: 'uninitialized'}]; this.columns = [{title: 'uninitialized'}];
this.columnDefs = []; this.columnDefs = [];
this.data = []; this.data = [];
this.cc = 1;
} }
static get properties() { static get properties() {
...@@ -39,6 +40,7 @@ class DataTableView extends LitElement { ...@@ -39,6 +40,7 @@ class DataTableView extends LitElement {
columns: { type: Array, attribute: false }, columns: { type: Array, attribute: false },
columnDefs: { type: Array, attribute: false }, columnDefs: { type: Array, attribute: false },
data: { type: Array, attribute: false }, data: { type: Array, attribute: false },
cc: {type: Number, attribute: 'columns-count'},
}; };
} }
...@@ -63,6 +65,12 @@ class DataTableView extends LitElement { ...@@ -63,6 +65,12 @@ class DataTableView extends LitElement {
set_datatable(data) { set_datatable(data) {
const lang_obj = this.lang === 'de' ? de : en; const lang_obj = this.lang === 'de' ? de : en;
if (this.cc > this.columns.length) {
for (let i = this.columns.length; i < this.cc; ++i) {
this.columns.push({title: ''});
}
}
this.table = $(this.shadowRoot.querySelector('table')).DataTable({ this.table = $(this.shadowRoot.querySelector('table')).DataTable({
destroy: true, destroy: true,
autoWidth: false, autoWidth: false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment