Replies: 4 comments 2 replies
|
For reference: |
1 reply
|
Oh no. Maybe I should use Fancytree for this feature :( |
0 replies
|
Something that can be done now (don't know if that was already the case when OP opened that discussion) is using e.tree.getState({"expandedKeys": true, "selectedKeys": true})in the Then use e.tree.setState(state);Minimal working example : data = [
{
title: "Node 1",
expanded: true,
children: [
{
title: "Node 1.1",
},
{
title: "Node 1.2",
},
],
},
{
title: "Node 2",
},
];
document.addEventListener("DOMContentLoaded", (event) => {
const tree = new mar10.Wunderbaum({
element: document.getElementById("demo-tree"),
source: data,
init: (e) => {
e.tree.setFocus();
if (localStorage.getItem("treeState") !== null) {
const state = JSON.parse(localStorage.getItem("treeState"));
e.tree.setState(state);
}
},
activate: (e) => {
localStorage.setItem(
"treeState",
JSON.stringify(e.tree.getState({"expandedKeys": true, "selectedKeys": true}))
);
},
expand: (e) => {
localStorage.setItem(
"treeState",
JSON.stringify(e.tree.getState({"expandedKeys": true, "selectedKeys": true}))
);
}
});
}); |
0 replies
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
What is the best way to cache the state of wunderbaum (nodes selected, lazy nodes already loaded) to allow it to survive a page refresh?
All reactions