我正在尝试使用 ngx-datatable 包在我的 Angular 4 应用程序中显示一些数据,我对设置列宽的“强制”模式特别感兴趣。据我了解,该模式应该根据单元格内容智能地确定列宽,以便所有内容都可见。但是,它对我不起作用。这些列的宽度设置为 150 像素,而不是它们各自的自定义宽度。
这是我的表格 HTML:
<ngx-datatable
[rows]="rows"
[columns]="columns"
[columnMode]="'force'"
[scrollbarV]="true"
[scrollbarH]="true"
[rowHeight]="50"
>
</ngx-datatable>
这是我的配置:
rows = [
{ displayName: 'Austin', emailAddress: 'a@a.aa', role: 'Swimlane',
a: 'This should all be visible and none of this should be cut off because the table is in force mode and it should keep it all visible' },
{ displayName: 'Dany', emailAddress: 'b@b.bb', role: 'KFC' , a:'b',
b:'This text should also be completely visible due to the selected display mode of "force"'},
{ displayName: 'Molly', emailAddress: 'c@c.cc', role: 'Burger King', a:'test', b: '3',
c: 'Aaaaaaaaaabbbbbbbbbbbbbbbbcccccccccccccccccccccc' },
];
columns = [
{ name: 'Name', prop: 'displayName' },
{ name: 'Email', prop: 'emailAddress' },
{ name: 'Role', prop: 'role'},
{ name: 'A', prop: 'a'},
{ name: 'B', prop: 'b'},
{ name: 'C', prop: 'c'}
];
Plunker 在这里显示问题: https ://plnkr.co/edit/KZHb2s0PPAiB7uPtwdIA?p=preview