问题描述
使用此库 https://bvaughn.github.io/react-virtualized/#/components/MultiGrid
我像这样创建了 multiGrid:
<MultiGrid
cellRenderer={cellRenderer}
columnCount={tableHeaders.length}
columnWidth={cache.columnWidth}
deferredMeasurementCache={cache}
height={height}
rowCount={data.length}
rowHeight={40}
width={width}
fixedRowCount={1}
enableFixedColumnScroll
enableFixedRowScroll
hideBottomLeftGridScrollbar={true}
hidetopRightGridScrollbar={true}
/>
如果添加 fixedCoulmnCount = {1}
它将冻结第一列,这很棒,但我需要使用函数发送该数字,以便我可以发送动态列号进行冻结。
有时我需要冻结第一两列,有时需要冻结第一三列
我尝试调用函数如下:
fixedColumnCount = {getFreezeColNo} //this is prop in multigrid to freeze coulmns
function getFreezeColNo() {
return 1;
}
我也尝试了箭头功能,例如:
fixedColumnCount={() => {
return 1;
}}
任何人都可以为此提供解决方案,在此先感谢
解决方法
fixedColumnCount 需要一个数字而不是一个函数,但您已经为其提供了一个函数,因此您收到了 NaN。通过实际调用 getFreezeColNo 函数来尝试一下。
fixedColumnCount = {getFreezeColNo()}