PrimeNG DataTable提供了[scrollable]定义垂直和/或水平滚动的属性。必须与set scrollHeight和/或组合使用scrollWidth。
我如何有一个可以调整窗口大小或保持滚动功能的表格?
这是我尝试过的代码:
<div class="ui-g-12">
<p-dataTable class="ui-g-12" [value]="rows" [hidden]="this.apiService.spinnerIsVisible"
[style]="{ height: 'fit-content', 'margin-top': '10px' }"
[resizableColumns]="false" columnResizeMode="fit" emptyMessage="No records found"
[responsive]="false"
[globalFilter]="tableSearch"
[editable]="true"
[scrollable]="true" scrollHeight="100%" scrollWidth="100%">
<p-header>
<button pButton type="button" icon="fa-refresh" (click)="refresh()" style="float:left"></button>
<label for="tableSearch">Global search: </label>
<input id="tableSearch" #tableSearch type="text" placeholder="type here">
</p-header>
<p-column
*ngFor="let col of cols" [header]="col" [field]="col"
[style]="{'width': '250px', 'min-width': '50px', 'word-wrap': 'break-word'}"
[sortable]="true"
[filter]="true" filterPlaceholder="" filterMatchMode="contains"
[editable]="true">
</p-column>
</p-dataTable>
</div>Run Code Online (Sandbox Code Playgroud)
但这仅解决了响应宽度问题。在屏幕截图中,您可以查看可水平滚动的表:

由于在百分比值的情况下的height属性p-dataTable是相对于父级的,因此我尝试div …
我正在使用Angular 5开发一个Web应用程序.我有JSON文件,如下所示:
[
{
"id": 0,
"title": "Some title"
},
{
"id": 1,
"title": "Some title"
},
...
]
Run Code Online (Sandbox Code Playgroud)
该文件存储在本地.我也有一个界面:
export interface Book {
id: number;
title: string;
}
Run Code Online (Sandbox Code Playgroud)
问题是我如何:
Book[]从这些数据创建一个类型数组?