Angular ngx-datatable 固定列宽不起作用

Angular ngx-datatable fixed column width is not working

我正在使用 swimlane 的 ngx-datatable。我需要为 table 中的几列指定特定宽度,但它不起作用。这就是我创建 table:

的方式

page.component.html:

<ngx-datatable [rows]="rows" [columns]="columns" rowHeight="auto" columnMode="force" [reorderable]="false" [swapColumns]="false"></ngx-datatable>

page.component.ts:

this.columns = [
   { prop: 'col1', resizeable: false, sortable: false, width: 30 }, 
   { prop: 'col2', resizeable: false }, 
   { prop: 'col3', resizeable: false, sortable: false }, 
   { prop: 'col4', resizeable: false, sortable: false },
   { prop: 'col5', resizeable: false, sortable: false, width: 30 }
];

the documentation 中所述,minWidth 属性 的默认值为 100。恕我直言,如果我们尝试定义一个小于 100width 值,那么我们也需要定义 minWidth 属性。

minWidth: number

Minimum width of the column in pixels. Default value: 100