SpecPersistence - mar10/fancytree GitHub Wiki
Trees should (optionally) maintain their status between page reloads.
This feature should be provided by the jquery.fancytree.persist.js
extension.
The 'jquery.fancytree.persist.js' extension is already available (demo).
Yet there are still open questions, so this feature is open for discussion and the API is subject to change.
Please discuss here: https://github.com/mar10/fancytree/issues/11
- When a page is refreshed, or visited after a given time, the tree status should be maintained.
- The tree state should be stored in cookies or session storage.
- This feature should be optional and configurable.
- Tree status is defined by
- active node
- focused node
- expansion state
- selection state
The feature is basically working, but currently there are some main issues and open questions:
-
Events
When node is re-activated, should theactivate
event be fired again?
-> Rather not, since this could easily be done callingnode.reactivate()
in theinit
event.
SeefireActivate
option -
Precedence
When we reload, and the tree data (or initial Ajax response) contains nodes with a status (i.e. active, expanded, selected) should we still override this with the cookie information? --> see `overrideSource``option -
Lazy trees
When a page with a lazy tree is reloaded, expanded nodes may no longer be available.
To retain the active node, it may be necessary reload its parent nodes via Ajax first. --> seeexpandLazy
option -
Multi-hier selection
This feature must be compatible withselectMode: 3
(see SpecSelect) --> We currently store only the key of selected top nodes usingtree.getSelectedNodes(true)
and callfixSelection3AfterClick()
for those nodes when they are restored.
TODO (see the demo)