reactjs - how to avoid whitespace on right side if columns are less in Ag grid
问题描述
The answer might be sizeTofit . But When I have to resize the column then that whitespace is coming on the right side of the grid.
So I need to do the last column of the grid to occupy the grid fully if columns are less (Or if I remove come column)otherwise it will take the column width provided by the property to Ag grid
This is the image I am getting now
like this I want
解决方案
如果它的大小不是您想要的,那么您可以编写一个函数并手动进行计算。
设置列的宽度,最后为您的 ag 网格设置新的列定义;
var tableWidth = sth;
var totalWidth = 0;
for(var i = 0; i<columnDefs.length; i++) {
totalWidth += columnDefs[i].width;
if((i == columnDefs.length - 1) && (totalWidth < tableWidth)) {
columnDefs[i] += tableWidth - totalWidth;
}
}
api.setColumnDefs(columnDefs);
推荐阅读
- c# - 在 ASP.NET MVC 中动态添加文本框
- angular - 选中和取消选中复选框取决于某些条件
- python - 如何从 Pyro Proxy 获取/配置套接字
- c - 声明一个没有参数的函数原型会造成安全漏洞吗?
- html - 如何在对齐文本中创建手动换行符
- node.js - 在 lambda 中安排 mongo db 议程
- html - Bootstrap 4响应式两列成一列堆叠,而不是打乱
- flutter - 如何在flutter中更改下拉值时调用api?
- java - 使用 JsonConvertor 和 AvroConvertor 发送 STRUCT 的默认值时 Kafka Connect API 错误
- python - 动画 GIF 仅在其第一帧上是透明的(Python PIL)