export class DataTableScrollDemo implements OnInit {
cars: Car[];
cols1: Column[];
cols2: Column[];
constructor(private carService: CarService) { }
ngOnInit() {
this.carService.getCarsMedium().then(cars => this.cars = cars);
this.cols1 = [
{field: 'vin', header: 'Vin',},
{field: 'brand', header: 'Brand'},
{field: 'year', header: 'Year'},
{field: 'color', header: 'Color'}
];
this.cols2 = [
{field: 'vin', header: 'Vin', style: 'width:250px'},
{field: 'brand', header: 'Brand', style: 'width:250px'},
{field: 'year', header: 'Year', style: 'width:250px'},
{field: 'color', header: 'Color', style: 'width:250px'}
];
}
}
<p-dataTable [value]="cars" [columns]="cols1" scrollable="true" scrollHeight="200">
<header>Vertical</header>
</p-dataTable>
<p-dataTable [value]="cars" [columns]="cols2" scrollable="true" scrollHeight="200" scrollWidth="75%" style="margin-top:30px">
<header>Vertical and Horizontal</header>
</p-dataTable>