admin管理员组文章数量:1320864
I am using ag-grid library for advanced data grid.
In ag-grid library, I can define "minWidth" and "maxWidth" attributes in "columnDefs" to set minimum and maximum width for particular column.
But is there any option to set default min and max width for each column to set re-sizing boundaries for columns?
I am using ag-grid library for advanced data grid.
In ag-grid library, I can define "minWidth" and "maxWidth" attributes in "columnDefs" to set minimum and maximum width for particular column.
But is there any option to set default min and max width for each column to set re-sizing boundaries for columns?
Share Improve this question edited Apr 26, 2016 at 17:53 Charlie 23.9k12 gold badges63 silver badges95 bronze badges asked Apr 22, 2016 at 23:42 SatAjSatAj 1,9795 gold badges32 silver badges49 bronze badges4 Answers
Reset to default 1Have a single function in the scope to define column widths and heights.
$scope.monWidth = function() {
return 50 + calcDynWidth(); //Dummy function
}
$scope.gridOptions = {
columnDefs: [
{headerName: 'Name', minWidth: $scope.monWidth()}
]
}
For AG Grid React, giving the maxWidth
and minWidth
in the column definition worked for me.
For eg:
const defaultColDef = {
minWidth:200,
maxWidth:400,
}
Here i'm setting the values as 200 and 400 which can be replaced by any variable value according to your use-case.
The same can be applied to individual column definitions also.
There is the auto-size-strategy which lets you define the default behavior for the grid which you can use like this.
const gridOptions = {
autoSizeStrategy: {
type: 'fitCellContents'
},
// other grid options ...
}
The next two Entries in the Docs might also be interesting. (autoSizeColumns, autoSizeAllColumns)
This works for me:
<ag-grid-angular
[defaultColDef]="defaultColDef"
public defaultColDef: ColDef = {
wrapHeaderText: true,
autoHeaderHeight: true,
minWidth: 100,
floatingFilterComponent: 'myCustomFilter',
filter: 'myCustomFilter',
type: ['defaultColumn'],
sortable: true,
};
The minWith property is the key
本文标签: javascriptHow to set default min and max column width in aggridStack Overflow
版权声明:本文标题:javascript - How to set default min and max column width in ag-grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742079714a2419624.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论