【问题标题】:How to make fixed columns dynamic using react-virtualized library如何使用反应虚拟化库使固定列动态化
【发布时间】: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


    【解决方案1】:

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

      fixedColumnCount = {getFreezeColNo()}
    
    

    【讨论】:

      猜你喜欢
      • 2017-08-20
      • 2018-01-23
      • 1970-01-01
      • 2019-06-12
      • 2017-05-15
      • 1970-01-01
      • 2019-01-20
      • 2017-04-28
      • 1970-01-01
      相关资源
      最近更新 更多