Comments (7)
Hi @andreskimlee
This looks similar to #7771
Could you check if using updateRows
solves your issue?
from mui-x.
Hi @andreskimlee This looks similar to #7771 Could you check if using
updateRows
solves your issue?
That seems to fix the issue in regards to updating an actual row, Any ideas on why opening a popover/menu causes the collapsed state to change back to default?
from mui-x.
Any ideas on why opening a popover/menu causes the collapsed state to change back to default?
I was not able to reproduce the mentioned issue in this codesandbox demo, probably you are updating some external variable on popover/menu open which is causing the Grid to re-render and recompute the Grid tree?
Could you provide a minimal reproduction test case with the latest version? This would help us understand the issue better. 👷
A live example would be perfect. This codesandbox example may be a good starting point. Feel free to fork it or start over from scratch.
Thank you!
from mui-x.
Any ideas on why opening a popover/menu causes the collapsed state to change back to default?
I was not able to reproduce the mentioned issue in this codesandbox demo, probably you are updating some external variable on popover/menu open which is causing the Grid to re-render and recompute the Grid tree?
Could you provide a minimal reproduction test case with the latest version? This would help us understand the issue better. 👷 A live example would be perfect. This codesandbox example may be a good starting point. Feel free to fork it or start over from scratch.
Thank you!
Was unable to reproduce via condesandbox so Its most likely an issue on our end. What im struggling to understand is why the sort state persists between re-renders but the collapsed state gets reset? Might be insightful to know how the row collapsed state in row grouping behaves differently from the sort state.
from mui-x.
That's actually a good question. It's by design, whenever the rows
prop is updated or apiRef.current.setRows
is called, the whole tree of rows is regenerated, as this update is supposed to be done when a full Grid row recalculation is needed, otherwise it's recommended to use partial rows update method apiRef.current.updateRows
which doesn't cause the expansion state to be lost. (Though I think this section of docs deserves some more explanation)
Regarding the application state other than rows (like filterModel
for example) it's not updated unless there's a trigger to update it, like controlled state being changed or some event firing which updates a part of the state.
I'd recommend you to read a more detailed explanation of the related problem faced by some users: #210 (comment)
Does that somewhat addresses your concern?
from mui-x.
That's actually a good question. It's by design, whenever the
rows
prop is updated orapiRef.current.setRows
is called, the whole tree of rows is regenerated, as this update is supposed to be done when a full Grid row recalculation is needed, otherwise it's recommended to use partial rows update methodapiRef.current.updateRows
which doesn't cause the expansion state to be lost. (Though I think this section of docs deserves some more explanation)Regarding the application state other than rows (like
filterModel
for example) it's not updated unless there's a trigger to update it, like controlled state being changed or some event firing which updates a part of the state.I'd recommend you to read a more detailed explanation of the related problem faced by some users: #210 (comment)
Does that somewhat addresses your concern?
Appreciate the quick response, that was super insightful.
So we found a solution (Albeit not optimal since we're masking the re-rendering issue lol) but for now,
the way we solved this issue was managing the row collapsed states ourselves
useEffect(() => {
apiRef.current.subscribeEvent('rowExpansionChange', (node) => {
expansionState.current[node.id] = node.childrenExpanded ?? false
})
}, [apiRef])
const isGroupExpanded = useCallback(
(node: GridGroupNode) => expansionState.current[node.id] ?? false,
[expansionState],
)
<DataGridPremium
isGroupExpandedByDefault={isGroupExpanded}
from mui-x.
So we found a solution (Albeit not optimal since we're masking the re-rendering issue lol)
Glad you found one, yeah, it would cause the Grid to re-render every time the rows
prop updates.
If possible, I'd recommend you to port to the more optimal solution to achieve a better performance.
Since the question is answered, I'll close the issue. Feel free to reopen if you face an issue again on the same topic or open a separate one if you have one on another topic.
Thank you again for using the X Data Grid. 🙂
from mui-x.
Related Issues (20)
- [question] HOT 3
- How to change the default date picker of column type date in my datagrid pro HOT 3
- Data Grid jitter on vertical scroll (Intermittent) HOT 2
- [docs] Demo BasicExampleDataGrid crashes: Paste with cmd+v(ctrl+v) for some types crashes
- DataGridPro Pagination calculation issue HOT 4
- [pickers] TimePicker disable text input HOT 3
- DataGrid filterOperators doesn't work with `getRowId` HOT 2
- [pickers] Integration with Storybook, LocalizationProvider error HOT 4
- [Tooltip] Tooltip on disabled buttons HOT 1
- [pickers] Localization is not applied to pickers HOT 8
- Add prop for column grouping header height HOT 3
- [data grid] Decreasing the width of the last column in DataGridPro with pinned columns results in weird behaviour HOT 4
- [docs] Demo LazyLoadingGrid crashes HOT 1
- How to animate row entrance? HOT 2
- AdapterDateFns not exported from x-date-pickers HOT 2
- [pickers] Consolidate `export` strategy HOT 1
- Source code of pro and premium packages HOT 6
- Data Grid Premium, Row grouping : How to conditionally change rows group background color ? HOT 6
- [DataGrid] All cells are all rerendered on every keystroke when row is in edit mode
- [pickers] When formatting a DatePicker Component with "DD MMM YYYY", default placeholder is "DD MMMM YYYY" HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mui-x.