gpt4 book ai didi

javascript - 如何根据单元格 Aggrid 中的元素自动调整 rowHeight

转载 作者:太空宇宙 更新时间:2023-11-04 08:50:36 24 4
gpt4 key购买 nike

我在我的元素中使用 aggrid,我想在我的行中实现一个自动调整大小的功能。意味着目前在我的每个单元格中都会有多个 div 元素。因此,如果我固定行的高度,如果我添加第三个 div,它就会隐藏或溢出。我怎样才能在 ag-grid 中防止这种情况?我还需要在单元格周围填充 10 的 div。我想我应该想出一些计算或者有没有可用的属性(property)?提前谢谢大家。

目前我有这段代码进行计算,返回值最终会传递给我的getRowHeight: this._getRowHeight:私有(private)_getRowHeight(_params:任何):数字{ 让 maxHeight: number = 100;

for (let i in _params.data) {
if (i != "time" && _params.data[i] instanceof Array) {
let tempHeight: number = 100 * _params.data[i].length;

if (tempHeight > maxHeight) maxHeight = tempHeight;
}
}
return maxHeight;

_params.data[i]的数据结构:

enter image description here

当我向我的内容中添加一个新对象时,出现了行高问题。我希望你们现在有了更好的主意。

最佳答案

您可以将 gridOption 的 rowHeight 重写为

gridOptions.rowHeight = $scope.tempRowHeight

根据动态属性,例如

$scope.addRow function(heigth) {
$scope.tempRowHeight = heigth;
refreshView();
}

关于javascript - 如何根据单元格 Aggrid 中的元素自动调整 rowHeight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43464616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com