TreeTable - Column Toggle This demo uses a multiselect component to implement toggleable columns.
{{col.header}} {{rowData[col.field]}}
View on GitHub

export class TreeTableColToggleDemo {

    files: TreeNode[];

    cols: any[];

    selectedColumns: any[];

    constructor(private nodeService: NodeService) { }

    ngOnInit() {
        this.nodeService.getFilesystem().then(files => this.files = files);

        this.cols = [
            { field: 'name', header: 'Name' },
            { field: 'size', header: 'Size' },
            { field: 'type', header: 'Type' }

        this.selectedColumns = this.cols;

View on GitHub

<p-treeTable [value]="files" [columns]="selectedColumns">
    <ng-template pTemplate="caption">
        <div style="text-align:left">
            <p-multiSelect [options]="cols" [(ngModel)]="selectedColumns" optionLabel="header"
                        selectedItemsLabel="{0} columns selected" [style]="{minWidth: '200px'}" defaultLabel="Choose Columns"></p-multiSelect>
    <ng-template pTemplate="header" let-columns>
            <th *ngFor="let col of columns">
    <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
            <td *ngFor="let col of columns; let i = index">
                <p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler>