簡體   English   中英

如何使用反應虛擬化庫使固定列動態化

[英]How to make fixed columns dynamic using react-virtualized library

使用這個庫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}它會凍結第一列,這很棒,但我需要使用 function 發送該數字,以便我可以發送動態列號以凍結。
有時我需要凍結第一兩列,有時需要凍結第一三列

我嘗試調用 function 如下:

fixedColumnCount = {getFreezeColNo} //this is prop in multigrid to freeze coulmns

function getFreezeColNo() {
    return 1;
  }

我試過箭頭 function 也喜歡:

fixedColumnCount={() => {
                return 1;
              }}

但是上面的代碼出現了這個錯誤:

在此處輸入圖像描述
任何人都可以為此提供解決方案,在此先感謝

fixedColumnCount 期望的數字不是 function,但您已向其提供了 function,因此您收到的是 NaN。 通過實際調用 getFreezeColNo function 來嘗試一下。

  fixedColumnCount = {getFreezeColNo()}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM