微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决Angular ngx-datatable 固定列宽不起作用

我正在使用 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',sortable: false },{ prop: 'col4',{ prop: 'col5',width: 30 }
];

解决方法

the documentation 中所述,const pets = [ { name: "dog",characteristics: new Set(["loyal","big"]),},{ name: "cat",characteristics: new Set(["fluffy","small"]),]; function filterPets(pets,characteristic) { return pets.filter(function(pet) { return pet.characteristics.has(characteristic); }); } 属性的默认值为 const pets = [ { name: "dog",characteristic) { return pets.filter(function(pet) { return pet.characteristics.has(characteristic); }); } console.log(filterPets(pets,"loyal")); console.log("Don't worry about the {} for characteristics,the Stack Snippets console doesn't know how to display Set objects. Look in the real console if you want to double-check the set.");。恕我直言,如果我们尝试定义一个小于 minWidth100 值,那么我们也需要定义 width 属性。

minWidth:数字

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。