| 23 | removeButton: gui.Button; |
| 24 | |
| 25 | constructor(public columns: ColumnDescriptor[]) { |
| 26 | for (const column of columns) |
| 27 | this.table.addColumn(column.title); |
| 28 | this.table.setHasBorder(true); |
| 29 | this.table.setStyle({flex: 1}); |
| 30 | this.table.onRowActivate = this.#editSelectedRow.bind(this); |
| 31 | this.table.onSelectionChange = () => { |
| 32 | const hasSelection = this.table.getSelectedRow() != -1; |
| 33 | this.editButton.setEnabled(hasSelection); |
| 34 | this.removeButton.setEnabled(hasSelection); |
| 35 | }; |
| 36 | this.view.addChildView(this.table); |
| 37 | |
| 38 | this.buttonsArea = new ButtonsArea({hideSeparator: true}); |
| 39 | this.removeButton = this.buttonsArea.addButton('Remove'); |
| 40 | this.removeButton.setEnabled(false); |
| 41 | this.removeButton.onClick = this.#removeSelectedRow.bind(this); |
| 42 | this.editButton = this.buttonsArea.addButton('Edit'); |
| 43 | this.editButton.setEnabled(false); |
| 44 | this.editButton.onClick = this.#editSelectedRow.bind(this); |
| 45 | this.view.addChildView(this.buttonsArea.view); |
| 46 | } |
| 47 | |
| 48 | setData(data: T[]) { |
| 49 | this.data = data; |