Code Monkey home page Code Monkey logo

Comments (3)

flaviendelangle avatar flaviendelangle commented on June 21, 2024 1

It's an interesting use-case
For me it can be done in user-land as you said, but maybe not in an optimal way.
To do it, you one way is to use multiSelect and control the selection using selectedItems and onSelectedItemsChange to select all the ancestors when selecting an item.
But since you are using multiSelect, the Tree View will allow stuff like range selection using Shift which may not be what the user want here. You may be able to opt-out of those behaviors using event.defaultMuiPrevented on the relevant event handlers, but this could be quite fragile.

The clean implementation would be to only display the ancestors as selected but not have it in the model, that way people can use multiSelect if they want or stay with single selection.
To do that in user land would require creating a custom TreeItem, control the selection and pass a prop on the item slot of the RichTreeView component (for SimpleTreeView the implementation would differ here) saying if the item is visually selected or not and re-apply manually the style if needed.

We should definitely do a recipe a see how viable each approach is and pick the best one.

from mui-x.

github-actions avatar github-actions commented on June 21, 2024

You have created a support request under the "Priority Support" terms, which is a paid add-on to MUI X Premium ⏰. Please validate your support key using the link below:

https://tools-public.mui.com/prod/pages/jyhs86t?repo=mui-x&issueId=13215

Do not share your support key in this issue!

Priority Support is only provided to verified customers. Once you have verified your support key, we will remove the support: unknown label and add the support: priority label to this issue. Only then the time for the SLA will start counting.

from mui-x.

michelengelen avatar michelengelen commented on June 21, 2024

Hey @amit-8
You can use the treeview public api for this. There is the getItem method with which you can get the parent item by its id. With this item you can do your modifications as needed.

@flaviendelangle should we document cases like this with a recipe as well?

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.