-
-
Notifications
You must be signed in to change notification settings - Fork 601
SpecSelect
Trees should support selection of one ore more nodes.
This feature is already implemented (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/12
- Nodes may have a state ´selected´, which is independent from the
active
state. - There must be a visual representation, that makes this distinguishable.
- The selection state must be easily queried by JS. It must also easily be submitted to the server.
- Selection must be controllable using events (i.e. return false on
beforeSelect
). - Selection must possible using checkboxes.
Checkboxes may be hidden globally or by node.
Checkboxes may be disabled globally or by node. - Selection must be possible using the API.
- We support different modes
-
1: single
Only one (or no) node is selected at any time. Selecting another node will deselect the previous. -
2: multi
No, one, or more nodes may be selected at any time. -
3: multi-hier
No, one, or more nodes may be selected at any time.
In this mode only the selection status of end nodes (i.e. leaves) is relevant!.
(De)selecting a parent node will (de)select all children.
If some (but not all) descendants of a node are selected, this node is displayed as 'partly selected'
-
1: single
The feature is basically working, but currently there are some main issues and open questions:
-
Precedence in simple mode
When the tree source data (or initial Ajax response) contains more than one selected node, should we fix it? If so: how? -
'unselectable' option
Nodes may be marked 'unselectable', which should prevent changing the selection state by user clicks.
An unselectable node by be initialized 'selected', which is fine. The user may not deselect it using a click.
(De)Selection using the API should still be possible(?) -
'unselectable' option in multi-hier mode
Should the unselectable node preserve its state when the parent is (de)selected? This would mean, that after selecting the parent, the parent is still marked 'partSel'.
Or we mark the parent 'selected', even if some children are unselectable. -
Precedence in multi-hier mode
When the tree source data (or initial Ajax response) contains inconsistent data, should we fix it?
If so: how?
Example: a node is marked as selected, but its children are not. Should we select all children, or deselect the parent? -
Lazy trees in multi-hier mode
When we select a lazy/unloaded node, this means 'select all children'.
Now we expand the parent, which triggers lazy loading. The response may contain unselected nodes; what now? -
Persistence
This feature must be compatible with persistence (see SpecPersistence)
We assume the following use case as most likely:
The server does maintain the tree structure, but not the selection state. For example we have a hierarchical structure of options, but any user will choose its own selection set.
If the user has finished its selections, she will submit this data to the server (or the selection set is only used by client-side JavaScript).
This allows the following decisions:
- When a user expresses a wish by actively selecting a node, this takes precedence.
So if we select a lazy parent, then expand it, all children are expected to be selected, even if the server sends them unselected. - If the server sends selected nodes, we treat this as initial default selection.
- If this data is inconsistent, we don't repair it!
But we should also make the following - less likely - use case possible:
The tree represents a single data model that is maintained on the server - or the server maintains the tree model by user. Selecting a node will modify the global data. If the tree sends selected nodes, this should take precedence.
TODO (see the demo)
Documentation Home - Project Page - Copyright (c) 2008-2022, Martin Wendt (https://wwWendt.de)