如何使用反应虚拟化库使固定列动态化

问题描述

使用此库 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;
              }}

但是我在上面的代码中遇到了这个错误

enter image description here


任何人都可以为此提供解决方案,在此先感谢

解决方法

fixedColumnCount 需要一个数字而不是一个函数,但您已经为其提供了一个函数,因此您收到了 NaN。通过实际调用 getFreezeColNo 函数来尝试一下。

  fixedColumnCount = {getFreezeColNo()}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...