React-data-grid: Wrong cell updated while rows are filtered

Created on 23 Nov 2016  路  2Comments  路  Source: adazzle/react-data-grid

I'm submitting a ... (check one with "x")

[ x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md

Current behavior
After filtering the grid to a few rows I try to edit a cell. After submitting the change, sometimes the cell is updated and other times it is not. This is because it is updating the cell that was originally in that space.

Expected/desired behavior

Reproduction of the problem

  • I have rows 1, 2, 3
  • I filter down to just row 2
  • If I update any cell in row 2, the changes will be saved to row 1 because it was sitting where row 2 is.

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Most helpful comment

i have an example of a filterable, sortable, editable table
https://just-warrior.glitch.me/

All 2 comments

Workaround has been implemented to avoid this bug.

  • FilteredRows must be tracked manually.
    ( I would suggest looping through your filters and filtering down from complete list of rows on every handleFilterChange. Then store your filteredRows in the state )
  • When implementing onRowUpdated, use filteredRows to find which row must be updated.
  • Find indexOf correct row in "rows" via rowKey in updated row.
    ( IE. let index = _.indexOf(rows, { 'ROWKEY': filteredRows[e.idx].ROWKEY }) )
  • Update correct row in "rows" and correct changes will be seen.
    ( Object.assign(row[index], e.update )

i have an example of a filterable, sortable, editable table
https://just-warrior.glitch.me/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martinnov92 picture martinnov92  路  3Comments

soma83 picture soma83  路  4Comments

JimLynchCodes picture JimLynchCodes  路  4Comments

localhosted picture localhosted  路  4Comments

GenoD picture GenoD  路  3Comments