So I am working on a feature for the table in my app. I have done an abstraction over the ngx-datatable as a component which acts as a facade for other components in my app (someComponent => FacadeTableComponent => Ngx-DataTable).
The columns are created in the FacadeTableComponent based on someComponent, and passed as an input to the NgxDataTable.
But now I want to add a tree view to the datatable (that works) but I want the FacadeTableComponent to set a default first column with a button that does the tree collapsing/expanding. So I thought that the default column could be defined as a ngx-datatable-column in the FacadeTableComponent html template. The problem seems that the input columns seem to overwrite my default column.
Now I tried to somehow grab the ngx-datatable-column with a @ViewChild and unshift it to the generated columns in the FacadeTableComponent, but I am not able to grab it as a directive, rather as a ElementRef.
I could of course just define a default column in the .ts file and generate it when I generate the rest of the columns, but I want to know if it is possible to do it the way I described it in the title.
The reason for this default column is that when I set one of the existing columns as a treeView column, the ngx datatable adds a default button, even if I provide my own template to the cell, and I want to provide my own button in the template.
<ngx-datatable #ngxDataTable class="datatable" [rows]="collection" [columnMode]="columnMode"
[footerHeight]="footerHeight" [selectionType]="selectionType" [sortType]="sortType" [sorts]="sorts"
[rowIdentity]="rowIdentity" [messages]="tableMessages" [selected]="selectedRows" [columns]="columns"
[headerHeight]="headerHeight" [rowHeight]="rowHeight" [scrollbarV]="true" [scrollbarH]="true"
(select)="onSelect($event)" (activate)="onActive($event)" [externalSorting]="true" [rowClass]="rowCssClass"
[sortType]="'single'" [treeFromRelation]="'MasterId'" [treeToRelation]="'id'"
(treeAction)="onTreeAction($event)" (sort)="sortRows($event)" (resize)="resizeTriggered($event)">
<!-- Datatable tree view column -->
<ngx-datatable-column #column_tree_view name="Tree" [isTreeColumn]="true" [width]="150"
[treeLevelIndent]="20">
<ng-template ngx-datatable-tree-toggle let-tree="cellContext">
<button [disabled]="tree.treeStatus==='disabled'" (click)="tree.onTreeAction()">
<span *ngIf="tree.treeStatus==='loading'">
...
</span>
<span *ngIf="tree.treeStatus==='collapsed'">
↑
</span>
<span *ngIf="tree.treeStatus==='expanded'">
↓
</span>
<span *ngIf="tree.treeStatus==='disabled'">
⃠
</span>
</button>
</ng-template>
</ngx-datatable-column>
<ngx-datatable>