File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ let response = JsonTree::new("customised-tree", &value)
37
37
.. Default :: default ()
38
38
}),
39
39
)
40
- . default_expand (DefaultExpand :: All )
40
+ . default_expand (DefaultExpand :: All ) // Expand all arrays/object by default.
41
41
. on_render (| ui , ctx | {
42
42
// Customise rendering of the JsonTree, and/or handle interactions.
43
43
match ctx {
@@ -62,8 +62,12 @@ let response = JsonTree::new("customised-tree", &value)
62
62
})
63
63
. show (ui );
64
64
65
- // Reset the expanded state of all arrays/objects to respect the `default_expand` setting.
66
- response . reset_expanded (ui );
65
+ // By default, the tree will expand/collapse all arrays/objects
66
+ // to respect the `default_expand` setting when it changes.
67
+ // If required, you can manually trigger this reset, e.g. after a button press:
68
+ if ui . button (" Reset" ). clicked () {
69
+ response . reset_expanded (ui );
70
+ }
67
71
```
68
72
69
73
## Supported JSON Types
Original file line number Diff line number Diff line change 32
32
//! ..Default::default()
33
33
//! }),
34
34
//! )
35
- //! .default_expand(DefaultExpand::All)
35
+ //! .default_expand(DefaultExpand::All) // Expand all arrays/object by default.
36
36
//! .on_render(|ui, ctx| {
37
37
//! // Customise rendering of the JsonTree, and/or handle interactions.
38
38
//! match ctx {
57
57
//! })
58
58
//! .show(ui);
59
59
//!
60
- //! // Reset the expanded state of all arrays/objects to respect the `default_expand` setting.
61
- //! response.reset_expanded(ui);
60
+ //! // By default, the tree will expand/collapse all arrays/objects
61
+ //! // to respect the `default_expand` setting when it changes.
62
+ //! // If required, you can manually trigger this reset, e.g. after a button press:
63
+ //! if ui.button("Reset").clicked() {
64
+ //! response.reset_expanded(ui);
65
+ //! }
62
66
//! # });
63
67
//! ```
64
68
//!
You can’t perform that action at this time.
0 commit comments