【问题标题】:Angular ngx-datatable fixed column width is not workingAngular ngx-datatable 固定列宽不起作用
【发布时间】:2021-07-26 11:05:59
【问题描述】:

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

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 }
];

【问题讨论】:

  • 您也可以尝试添加这些属性吗? minWidth: 30, maxWidth: 30
  • @Akif 成功了!为什么它起作用了? :D
  • 天意...

标签: angular typescript ngx-datatable


【解决方案1】:

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

最小宽度:数字

列的最小宽度(以像素为单位)。默认值:100

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多