Initial situation:
documenTree has an option “checkboxes” (combined with links=“false”) to allow multiple selections of tree elements.
A typical application in my environment is the generation of a list of documents to be revised.
These can be processed e.g. by Javascript routines get_json, get_selected within jstree (see below)
But if you want to select the “WebHome” document only:
- A selection of the node will select all children elements
- A multiple single select of all children elements will automatically select the node.
From a point of “tree view”: Conceptually, this is perfectly fine.
But the problem remains: How to select “WebHome” only?
A suggestion for improvement:
If the “WebHome” document is listed as an leaf item (HTML li element) additionally the
additional function wil be provided.
To remain downward compatible, an additional parameter should be introduced (e.g. showWebHome)
Any suggestion for a different way to achieve this is of course welcome.
Thanks
Norbert
Additional note: conceptional javascript
function showMyTree () {
require(["jquery"], function($) {
// get all:
// var v = $("#selectedTreeDocuments .xtree").jstree(true).get_json("#",{flat:true});
// get selected only:
var v = $("#selectedTreeDocuments .xtree").jstree(true).get_selected("full",true);
// more - see: https://www.jstree.com/docs/
var result = "";
function lister (item,index) {
if(item.state.selected) {
result = result + item.id + " (" + item.text+")\n\n";
};
};
// v.forEach(lister);
// debug: alert(result);
// debug: console.log(v);
});
};