gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.7k stars 931 forks source link

Expandable rows not working correctly while working with server data #755

Closed magda-tatarynowicz closed 5 years ago

magda-tatarynowicz commented 5 years ago

Expected Behavior

When using option serverSide:true, when data in table changes, expanded rows should collapse or it should be possible to manage their state through options.

Current Behavior

Currently rows stay expanded after getting new data (for example by changing page, sorting or filtering).

Steps to Reproduce (for bugs)

Example on codesandbox: https://codesandbox.io/s/awesome-flower-urwc8

  1. Expand first row
  2. Select next page

You can see that after changing the page row stays expanded, even though there is different data in the table. When data changes, row should collapse.

Your Environment

Tech Version
Material-UI 4.2.0
MUI-datatables 2.6.1
React 16.8.6
browser
etc
gabrielliwerant commented 5 years ago

I think the best resolution here is to provide a rowsExpanded option that works similarly to the rowsSelected option, so that the state of expandable rows is customizable.

This should also help resolve https://github.com/gregnb/mui-datatables/issues/549, https://github.com/gregnb/mui-datatables/issues/724, https://github.com/gregnb/mui-datatables/issues/518, https://github.com/gregnb/mui-datatables/issues/433, and possibly others.

lnaia commented 5 years ago

@gabrielliwerant I'm trying to tackle that option on #800 any feedback would be most appreciated.

gabrielliwerant commented 5 years ago

No need @Inaia, I've already assigned myself to this issue and am working on it. It will be in the next release.

gabrielliwerant commented 5 years ago

Feature added in 2.7.0. Let me know if this satisfies your issue. @lnaia

frahman5 commented 5 years ago

@gabrielliwerant I am trying to use rowsExpanded but it does not work on my machine. Using version 2.8.0. One thing to note is that the type definition for options in the accompanying index.d.t.s file doesn't have a rowsExpanded in the interface for Options. Is this perhaps a bug?

gabrielliwerant commented 5 years ago

@frahman5 This project does not officially support ts, so any ts support is supplied by users via the definitely typed project (so, not a bug,technically). I'm going to close this particular issue as resolved, but feel free to open a new issue if you have a bug to report, ideally with a minimal example written in js and added to a codesandbox so I can interact with it and we can be sure we're looking at the same thing.