In Nebular Tree Grid, how to add custom columns that aren't really linked to data? eg: add, edit, delete columns. I've just assigned them to properties of my class (ref, city, address), but what if the class definition didn't have "spare" properties? How to add extra columns?
In treegrid.component.ts:
nameColumn = 'name';
editColumn = 'ref';
addColumn = 'city';
deleteColumn = 'address';
defaultColumns = [ 'description' ];
allColumns = [ this.nameColumn, ...this.defaultColumns, this.editColumn, this.addColumn, this.deleteColumn ];
headers = ['Name', 'Description', 'Edit', 'Add', 'Delete'];
In treegrid.component.html:
<table [nbTreeGrid]="datasource" [nbSort]="datasource" (sort)="updateSort($event)">
<tr nbTreeGridHeaderRow *nbTreeGridHeaderRowDef="allColumns"></tr>
<tr nbTreeGridRow *nbTreeGridRowDef="let row; columns: allColumns"></tr>
<ng-container [nbTreeGridColumnDef]="nameColumn">
<th nbTreeGridHeaderCell [nbSortHeader]="getSortDirection(nameColumn)" *nbTreeGridHeaderCellDef>
{{headers[0]}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">
<mybe-fs-icon [children]="row.children" [expanded]="row.expanded"></mybe-fs-icon>
{{row.data[nameColumn]}}
</td>
</ng-container>
<ng-container *ngFor="let column of defaultColumns; let index = index"
[nbTreeGridColumnDef]="column"
[showOn]="getShowOn(index)">
<th nbTreeGridHeaderCell [nbSortHeader]="getSortDirection(column)" *nbTreeGridHeaderCellDef>
{{headers[index+1]}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">{{row.data[column] || '-'}}</td>
</ng-container>
<ng-container [nbTreeGridColumnDef]="editColumn">
<th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
{{headers[headers.length - 3]}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">
<nb-icon icon="edit-2-outline" (click)="editOrg(row.data)"></nb-icon>
</td>
</ng-container>
<ng-container [nbTreeGridColumnDef]="addColumn">
<th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
{{headers[headers.length - 2]}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">
<nb-icon icon="plus-circle-outline" (click)="addOrg(row.data)"></nb-icon>
</td>
</ng-container>
<ng-container [nbTreeGridColumnDef]="deleteColumn">
<th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
{{headers[headers.length - 1]}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">
<nb-icon icon="minus-circle-outline" (click)="confirmDeleteOrg(row.data)"></nb-icon>
</td>
</ng-container>
</table>