New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple expandable datagrids: expanding a row triggers all datagrids to expand #9688
Comments
Thank you for opening this issue. Indeed, currently the expand controller uses a Store key built only with the resource: There is currently no way to override that store key (except passing a different resource). We could introduce the ability to customize this store key (using e.g. the storeKey prop from the ListContext), but this would be a new feature. Would you like to open a PR (against the |
I will take a look. |
@slax57 I just came to ask this same question. Very annoying you can't pass storeKey down to the list context inside ArrayField. I would absolutely love this. Is there any work around or should we just create a new implementation of ArrayField for now? |
@davidhenley I was about to implement this, but I wasn't sure what would be the best approach. I asked about it on Discord but never got a reply so I forgot the whole thing 🙈 |
@roxeteer I'm digging through the ListContext source code right now, and am trying the same. It should be as simple as adding a prop and passing it down unless I'm missing something as the List just passes it to ListBase which passes it to the ListContext. |
@davidhenley I think the more React Admin-like approach would be to create yet another context for it. |
I don't understand this logic, it would be the exact same as it is now, just pass it to ListContext under ArrayField. What am I missing? |
Maybe I was thinking it too complicated. It's been a while already so can't remember how it was exactly. |
What you were expecting:
When I click to expand a row in a datagrid, only that row should expand.
What happened instead:
If I have multiple expandable datagrids on the same page, the same row in all of them expand (i.e. if I click the first row, the first row of all datagrids expand).
Steps to reproduce:
Related code:
The issue arises because all the datagrids use the parent resource name as the
localStorage
key. In this case expanding the first row of either of the datagrids stores["row0"]
with the keyRaStore.Product.datagrid.expanded
.Other information:
Since expand uses
<Datagrid>
'sresource
prop value in creating thelocalStorage
key, setting the prop to a unique string makes thelocalStorage
key unique as well. However, I'm not entirely sure what elseresource
prop is used for here and if it creates side-effects. Like this:Environment
The text was updated successfully, but these errors were encountered: