virtualized-table-for-antd icon indicating copy to clipboard operation
virtualized-table-for-antd copied to clipboard

Doesn't work with immutable records

Open Vincz opened this issue 2 years ago • 3 comments

I'm working with GraphQL generation and the records of my data source are immutable (non extensible objects) (see: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions).

So this line: https://github.com/wubostc/virtualized-table-for-antd/blob/66f0e80c6a82e70b25574c36c4b6b39e3f81b73f/src/vt.tsx#L727 doesn't work and triggers the following error: TypeError: Cannot add property Symbol(idx), object is not extensible

Would it be another way to keep the index? Maybe with a map using rowKey as key?

Vincz avatar Jul 26 '22 15:07 Vincz

Every row needs an index that held with the prop record, which I can determine the true index number of every row, and don't worry about whether the dataSource is a tree-structure or a nested-structure.

To solve this problem, I have to write something like row.props.record[row_idx] to keep a true index number

Could you solve this problem instead of that I mentioned above, and create a new PR with a branch?

Tips: there are a few things need to be changed below (at least)

  1. Initial state within VTWarpper https://github.com/wubostc/virtualized-table-for-antd/blob/66f0e80c6a82e70b25574c36c4b6b39e3f81b73f/src/vt.tsx#L727
  2. Running state within VTWarpper https://github.com/wubostc/virtualized-table-for-antd/blob/66f0e80c6a82e70b25574c36c4b6b39e3f81b73f/src/vt.tsx#L791
  3. Determining the true index number within VTRow https://github.com/wubostc/virtualized-table-for-antd/blob/66f0e80c6a82e70b25574c36c4b6b39e3f81b73f/src/vt.tsx#L841

wubostc avatar Jul 27 '22 03:07 wubostc

Has there been any progress on this? I am now running into this issue too.

PunkOnWheels avatar Sep 27 '22 07:09 PunkOnWheels

@PunkOnWheels I haven't had any ideas so far 0147C7AE

wubostc avatar Sep 27 '22 09:09 wubostc

Hi @wubostc Made an attempt here: https://github.com/wubostc/virtualized-table-for-antd/pull/132

Vincz avatar Dec 04 '22 10:12 Vincz

@Vincz @PunkOnWheels solved! 👍

wubostc avatar Dec 08 '22 11:12 wubostc