如何获取ag-grid中Row的样式对象?

How to get the style object of a Row in ag-grid?

我需要在不使用

的情况下获取 ag-grid 中一行的样式对象
document.querySelector(`[row-index="${rowIndex}"]`).style

有没有办法从 RowNode 或其他任何地方获取它?

除了你问题中的代码。不,你不能。如果你看source code。他们不在内部保存任何样式对象。

RowComp.prototype.postProcessStylesFromGridOptions = function () {
    var rowStyles = this.processStylesFromGridOptions();
    this.eAllRowContainers.forEach(function (row) {
        return addStylesToElement(row, rowStyles);
    });
};

这里是 addStylesToElement() 的定义。如您所见,styles 直接应用于 DOM 元素。

export function addStylesToElement(eElement, styles) {
    if (!styles) {
        return;
    }
    Object.keys(styles).forEach(function (key) {
        var keyCamelCase = hyphenToCamelCase(key);
        if (keyCamelCase) {
            eElement.style[keyCamelCase] = styles[key];
        }
    });
}