How can you set the columns of a DetailsList to a specific width at mount?k
I wanted to save the column widths every time they are saved and restore them when the component remounts, i.e., revisits the view where the list is.
How can you set the columns of a DetailsList to a specific width at mount?k
I wanted to save the column widths every time they are saved and restore them when the component remounts, i.e., revisits the view where the list is.
return [...staticColumns, ...visibleColumns.map(c => {
return {
key: c.Name,
name: c.Title,
fieldName: c.Name,
minWidth: 100,
isResizable: true,
isCollapsible: true,
onRender: (item: any, index: number, column: IColumn) => {
column.minWidth = 20;
return <span>{item[c.Name]}</span>;
},
} as IColumn;
})];
First set initial minWidth: 100
, then change to 20 in the onRender
callback. It's work for me