Comments (3)
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.
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.
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)
- [data grid] Toolbar button `slotProps` get overwritten by `slotProps.baseButton`
- [charts] Separate tick labels vs data labels for bar charts HOT 4
- [data grid] Save and restore filtermodels HOT 1
- [charts][core] Replace useIsomorphicLayoutEffect of @react-spring/web for Base UI's helper HOT 5
- [data grid] Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release HOT 3
- [pickers] Issue with JAWS on DateTimePicker component v5.0.20 HOT 1
- [data grid] Columns selection component losing anchorElement/scroll state HOT 5
- [data grid] Lazy loading details when using Master detail feature HOT 4
- [pickers] How to customize the `DatePicker` calendar header? HOT 2
- [data grid] License works locally but not on Vercel production HOT 3
- [data grid] Extra space on the bottom of grid when loading new records and scrolling back up HOT 1
- [data grid] filter and columns poppers incorrectly positioned when using a toolbar HOT 1
- [data grid] Bottom border doesn't reflect on pinned columns HOT 6
- [data grid] Deleting a row on cell Key down triggers an error HOT 2
- [pickers] add option to open calendar popover when text field is selected HOT 4
- [data grid] Is there a way to ignore the actions columns on paste in the data grid? HOT 2
- [charts] hovering over charts causes 'maximum update depth exceeded' error HOT 6
- [data grid] Is it possible to add reusable DataGrid GridToolbar components that make use of slots and slotProps? HOT 2
- [data grid] When wrapping custom renderHeader components in a Tooltip, it alway shows on hover, still appearing when there is no ellipsis HOT 3
- [TreeView] Can't type a space in an input rendered in the item 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.