【发布时间】:2021-05-25 21:29:51
【问题描述】:
使用这个库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;
}}
但是上面的代码出现了这个错误:
【问题讨论】:
标签: javascript reactjs react-virtualized