Giter Site home page Giter Site logo

Comments (4)

michelengelen avatar michelengelen commented on June 20, 2024

Hey @mtr1990
This is not a bug in the data grid, but rather an implementation issue.

When selecting an item inside from the MultiSelect it will cause a state change and therefore a re-render of the grid. You can prevent that by moving the state handling inside of the MultiSelect component.

When you provide that to the toolbar slot it does not re-render the whole grid with every change. This is also way more efficient.

Here is your example, but with an altered way of rendering the MultiSelect: Multi-Select example

I guess you will need the values set in the MultiSelect for the grid, so you could then pass the values back when closing/bluring the MultiSelect, or provide it through a global state management, etc.

I hope this helps! If not please feel free to ask! ๐Ÿ’ช๐Ÿผ

from mui-x.

mtr1990 avatar mtr1990 commented on June 20, 2024

Hi @michelengelen ,

Thanks for responding and providing a solution.

My aim is to get the values โ€‹โ€‹from MultiSelect and use this to filter data from the grid.

However, I don't know how to get these values โ€‹โ€‹exactly with the desired behavior of selecting multiple items in one go.

The global state appears ready to do this. But it wouldn't be suitable in my case. Do you have any other ideas or solutions?

https://codesandbox.io/p/sandbox/datagrid-forked-spsjsc?file=%2Fsrc%2FApp.tsx%3A61%2C8

from mui-x.

michelengelen avatar michelengelen commented on June 20, 2024

Hey @mtr1990

So, when you need the values set in the MultiSelect component you can just pass a handler into the component that gets called in the onClose or onBlur method.

Here is a working example, logging the selected names in the console when the select closes.

This is where you can then update the filtering with the apiRef from the datagrid.
Let me know if you need more help with this.

Thanks! ๐Ÿ™‡๐Ÿผ

from mui-x.

mtr1990 avatar mtr1990 commented on June 20, 2024

Hi,

I think this is a limitation. The expected behavior is that the values โ€‹โ€‹change on the select event (onChange) instead of onClose oronBlur.

However I am satisfied with this solution. Thank you for your help!

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.