I have created a datatable in angular 4 using prime ng primeface. I am able to bind the table from remote server. I have given the column name and header like
{ field: 'StudentId', header: 'Student Code' },
{ field: 'Dept', header: 'Department' },
{ field: 'PassoutYear', header: 'Passout Year' },
and Html will be like
<p-dataTable #dt [value]="Studentlist" exportFilename="Studentlist" reorderableColumns="true" resizableColumns="true" columnResizeMode="expand" selectionMode="single" [(selection)]="selectedCar" (onRowSelect)="onRowSelect($event)" [responsive]="true" [rows]="8" [paginator]="true" scrollHeight="300px">
<p-header>STUDENT RECORDER</p-header>
<p-header>
<div style="text-align:left">
<p-multiSelect [options]="columnOptions" [(ngModel)]="cols"></p-multiSelect>
</div>
</p-header>
<p-column *ngFor="let col of cols" [field]="col.field" [header]="col.header" [sortable]="true" [filter]="true" [editable]="true" filterMatchMode="startsWith" filterPlaceholder="Search"></p-column>
But here I want to display the data table dynamically. I.e. the number of columns will not be fixed. So my table should accept even it is a single column or it is any number of columns. How it is possible?