| Issue 176: | Add an additional selectMode to allow single item selection in multi-select mode | |
| 4 people starred this issue and may be notified of changes. | Back to list |
It would be great to add a new selectMode, eg: selectMode: 4, which allows for the selection of a single item under a parent without having to cascade selections back up the tree. At the moment if using selectMode: 3 it all works fine if you're selecting branches from the top down, whereas if you want to select from the bottom up it is incorrect. If for example you have just one parent branch with one child, this mode would allow you to select just the child and not the parent also. This allows for actions on just the individual branch as it will be the only one selected and not the full parental tree.
Oct 19, 2011
This can be currently enforced in selectmode : 3 itself by commenting out lines 885 to 900 in the jquery.dynatree.js file. Just did it for a project of mine. In case it helps out anyone.
Jan 22, 2012
I commented out lines 885-900 as well as lines 909-921. They're in the attached file for easy reference.
Disabling those blocks allows you to have a child selected while it's parent is not. That's what I want. There is still one problem, however.
Upon initial page load, the parent is displayed as selected if any of it's children are. In my case, I only want the boxes to be checked if the element is explicitly marked as being selected.
I tried to get around this by setting the "select" attribute to false, but that didn't work, the box was still checked.
Example (both are checked on page load, only Child should be):
children: [
{title: "Parent", key: "1", select: false, isFolder: true, expand: true,
children: [
{title: "Child", key: "2", select: true},
]
},
]
Is there an easy way to work-around this, i.e. looping through all elements on page load and unchecking them if the "select" attribute is set to false?
May 1, 2014
As of 2014 Dynatree is feature frozen. Please have a look at Fancytree (sequel of DynaTree 1.x): chances are good that the problem was resolved / the requested featuer is already implemented. Please open a new issue there otherwise: https://github.com/mar10/fancytree
Status:
WontFix
|
Adding some snippets from the previous mail discussion: This is a slightly different use case then mode 3 was designed for. Mode 3 assumes that a folder is not selectable by its own - it is only a container for selectable end nodes. Mode 4 would allow to have a parent selected, even if some children are deselected. It is rather related to Mode 2 (multi-select) with some enhanced behavior. Mode 4 would allow to behave like Mode 3 in these cases: - selecting a folder (or parent document) would select all descendants. - deselecting a folder (or parent document) would deselect all descendants. - selecting the a child - but there are still unselected children - will set the parent to 'partly selected' - deselecting the a child - but there are still selected children - will set the parent to 'partly selected' it would be different in these cases - selecting a child will *not* select the parent, even if now all children are selected. If the parent was deselected, it will be displayed as 'partly selected'. - deselecting a child will *not* deselect the parent, even if now all children are deselected. If the parent was displayed as partly selected before, it will now be 'unselected'. I think a prototype of this behavior could be implemented by enabling selectMode=2 and using onSelect(), onClick(), ... handlers, where we could call node.visit(), subNode.select() etc.Labels: Milestone-Discussion