angular - Angular2 setting property in a table column programmatically -
i using primeng2 , set frozen columns
i retrieving columns rest api in json form
colheaders:any[] = []; getcolumnheaders(){ this.bookservice.getcolumns() .subscribe( res=>{ this.colheaders = res } ) } on html have
<p-datatable [value]="cars" scrollable="true" frozenwidth="1200px" unfrozenwidth="600px" [style]="{'margin-top':'30px'}"> <p-column sortable="true" *ngfor="let col of colheaders" [field]="col.field" [header]="col.header" [frozen]="col.frozen"></p-column> </p-datatable> the above p-column fails when setting value false
in quick googling found need not set value of frozen whether true or false
so frozen columns should have like
<p-column sortable="true" [frozen]="true"></p-column> and unfrozen columns should have
<p-column sortable="true"></p-column> //no frozen property so how go it
so in normal words should this
<p-column sortable="true" *ngfor="let col of colheaders" * *ngif="(col.frozen)" //stuck on how go on ></p-column>
wrap <p-column> tag ng-container, doesn't have dom representation, , move ngfor in it. can keep ngif in p-column:
<p-datatable [value]="cars" scrollable="true" frozenwidth="1200px" unfrozenwidth="600px" [style]="{'margin-top':'30px'}"> <ng-container *ngfor="let col of colheaders"> <p-column sortable="true" [field]="col.field" [header]="col.header" *ngif="col.frozen" [frozen]="true"></p-column> <p-column sortable="true" [field]="col.field" [header]="col.header" *ngif="!col.frozen"></p-column> </ng-container> </p-datatable>
Comments
Post a Comment