Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular2:如果整个表列中的值相同,则使用PrimeNG动态隐藏列_Angular_Datatable_Primeng_Dynamic Columns - Fatal编程技术网

Angular2:如果整个表列中的值相同,则使用PrimeNG动态隐藏列

Angular2:如果整个表列中的值相同,则使用PrimeNG动态隐藏列,angular,datatable,primeng,dynamic-columns,Angular,Datatable,Primeng,Dynamic Columns,我正在使用带Angular2(11)的素数,我不熟悉Angular2。我有一个列为“公司名称”的表。有时,公司名称的值在每一行中都是相同的。如果每一行的值都相同,如何动态隐藏该列的默认值或将其设置为false(隐藏),并在其值不同时显示该列。下面,我已经在使用PrimeNG的切换功能来显示/隐藏列 这是我的密码: TS: HTML: 行动 {{col.header}} {{employees[col.field]} cols: any[]; _selectedColumns: any[];

我正在使用带Angular2(11)的素数,我不熟悉Angular2。我有一个列为“公司名称”的表。有时,公司名称的值在每一行中都是相同的。如果每一行的值都相同,如何动态隐藏该列的默认值或将其设置为false(隐藏),并在其值不同时显示该列。下面,我已经在使用PrimeNG的切换功能来显示/隐藏列

这是我的密码:

TS:

HTML:


行动
{{col.header}}
{{employees[col.field]}
cols: any[];
_selectedColumns: any[];

ngOnInit(): void {

    this.cols = [
    { field: 'EmployeeId', header: 'Employee ID', default: true },
    { field: 'AltId', header: 'Alt ID', default: false },
    { field: 'FirstName', header: 'First Name', default: true },
    { field: 'LastName', header: 'Last Name', default: true },
    { field: 'CompanyName', header: 'Company', default: true },
    { field: 'LocationName', header: 'Location', default: true },
    { field: 'RegMode', header: 'Primary Reg Mode', default: true },
    { field: 'AlternateDotRegulatoryMode', header: 'Alt Reg Mode', default: false },
    { field: 'NonDotRegulatoryModesString', header: 'Operators', default: true},
    { field: 'EmployeeCategory', header: 'Employee Categories', default: false},
    { field: 'InactiveStatus', header: 'Status', default: true },
    { field: 'Occupation', header: 'Occupation', default: true }
];

this._selectedColumns = this.cols.filter((col) => col.default);

}
<!-- TABLE HEADER BEGINS -->
<ng-template pTemplate="header" let-columns>
<tr>
<th style="width: 10%;">Actions</th>
<th *ngFor="let col of columns" [pSortableColumn]="col.field">{{col.header}}<p-sortIcon [field]="col.field"></p-sortIcon>
</th>
</tr>
</ng-template>

<!-- DATA TABLE BEGINS -->
<ng-template pTemplate="body" let-employees let-columns="columns">
    <tr>
        <td *ngFor="let col of columns">
            {{employees[col.field]}}
        </td>
    </tr>
</ng-template>