Code Monkey home page Code Monkey logo

Comments (4)

michelengelen avatar michelengelen commented on September 7, 2024

Hey @Chris-FSE you can save and restore the DataGrid state with the apiRef. There is a section about this in the docs.

The rows update re-rendering the grid and therefore resetting the column state is due to a misused column prop. These are constants and should be handled like that. You can either memoize the column definitions inside the component or just define them outside of the component.

I have updated the demo from the docs about the row updates to showcase that: demo.

from mui-x.

Chris-FSE avatar Chris-FSE commented on September 7, 2024

Hey @michelengelen thank you for your help.
Indeed, in the meantime I had found for my part by coming across examples of the use of states that the definitions of the columns must be outside the body of the component.
I think it would be interesting to notify this in the documentation.
Is this a library bug? Because even if the columns are defined in the component, the state management should work, right?
In my case I have very specific column renderings which depend on declared variables and managed only in the component body. So I will to memoized and see if it's work then, because it's not obvious...

from mui-x.

Chris-FSE avatar Chris-FSE commented on September 7, 2024

The memoize option also works like exporting the column definition out of the component.
Thanks again for the information.
This is better for me because the column definitions depend on component variables.
I'm just curious to know if it's a bug from the lib or not.
And I think that you can close the issue now.

from mui-x.

michelengelen avatar michelengelen commented on September 7, 2024

Right ... memoization is a different possibility.
I will close this now as the opening question seems resolved.
Feel free to reopen if you have follow up questions. 🙇🏼

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.