| Issue 91: | Optimize implementation of persistance | |
| 1 person starred this issue and may be notified of changes. | Back to list |
There is a need to rethink the way that persistance works (Because the current implementation is too complicated to explain to a ten-year-old :-)
Apr 27, 2009
Fixed with release 0.5. See https://code.google.com/p/dynatree/wiki/UpdateToVersion05 (Still alpha and open for comments!)
May 28, 2009
(No comment was entered for this change.)
Status:
Fixed
Jul 17, 2012
considered verified
Status:
Verified
Blocking: -dynatree:83 |
Current status and analysis Currently selection, focus and activation is applied, after the tree is loaded. No matter, if the tree status was loaded from source (UL tag, or JS object) or re-loaded using cookies in persist mode. (Expansion is not fired, it is simply renderd from cookie or source status) The rationale is, that after reloading a page, the application might want to re-apply the previous user actions. For example if the application displays node details, it will most likely hook the onActivate event. When the user reloads the page (and persistance is on), the tree will be restored, and an activate event is fired: The onActivate event is called again, and re-display the current node info. Another reason was, to enforce some rules, that are defined in the tree options. These are implemented in the default event handlers. - activate expands folders sometimes - select may deselect all other nodes - expand sometimes collapses siblings - select also select subnodes in certain modes Some of these rules cannot be applied during the load phase, because not all nodes are present then. So we have to have a post-load pase. Problems with the current approach - complicated, unexpected behavior to most developers - Possible side effects make the sequence order critical: - activate() may expand a folder if clickFolderMode is '3' - activate() may collapse it's siblings - activate() may expand it's parents - collapse() may deacivate or remove focus - select() may select sub nodes. - select() may deselect other nodes. - select() may fire an event, but the lazy node are not yet there. - have to check for tree.isInitializing() in event handlers - doesn't work with lazy nodes anyway, if the active node is not yet loaded. In this case we propose that we send the persist info with the Ajax request. The server is expected to return a tree with proper attribute settings. Solution / proposed changes: - Persistence should only restore a previous configuration. It should not be necessary to enforce consistency rules, since we assume a consistent source. - Persistence should not fire events. Selection or activation of a node by a user may lead to an expensive operation in the backend. It should not automatically be re-triggered, just because the user refreshed the page. - Yet, persistence should make it easy to re-fire events. While we should not automatically fire events, we should make it easy to do so, because sometimes focus and activation events are handled by simply displaying some node info. This should easily be re-triggered in an onPostInit event. - Persistence should not hinder lazy trees. It must work when re-loading a completely lazy tree (that uses initAjax) And it must work, when a lazy tree was reloaded, but some branches are expanded later: in this case appendAjax should consider cookies.