Auto expand all & Search
Closed this issue · 2 comments
g-tejas commented
Is there a way to use defaultexpand:All and the searchfunctionality as well? I'd like the json tree to be fully expanded when the gui opens instead of collapsed, but im not sure if i can enable both
dmackdev commented
You could try switching between using DefaultExpand::All and DefaultExpand::SearchResults(_) based on whether your search term is empty, e.g.:
let default_expand = if search_input.is_empty() {
DefaultExpand::All
} else {
DefaultExpand::SearchResults(&search_input)
};
let response = JsonTree::new("", &value)
.default_expand(default_expand)
.show(ui);You can amend the SearchExample in examples/demo.rs to try this out. Let me know if that works for you!
g-tejas commented
Coincidentally went along with the same method, though your method is much shorter, thanks this works well!