[英]How to get all the IDs of selected nodes to root node in jsTree?
How to get IDs of selected nodes to root node in jsTree? 如何将选定节点的ID获取到jsTree中的根节点?
Assume F and D are selected nodes , I want to get all the ids include ABCDF 假设F和D是选定的节点,我想获取所有id包括ABCDF
Following code will return only immediate selected ids D and F 以下代码将仅返回立即选择的ID D和F
var getMenuIds = function(){
var menuIds = $("#menu-tree").jstree("get_checked");
window.alert(menuIds.join(","));
$('#menuIds').val(menuIds.join(","));
}
Is there any way to get all parent nodes ID ie Selected node to root node ? 有什么方法可以获取所有父节点ID,即“选定节点”到根节点吗?
Call get_path to get the path to each selected node. 调用get_path获取到每个选定节点的路径。
Something like: 就像是:
var tree = $("#menu-tree");
var menuIds = tree.jstree("get_checked");
var paths = menuIds.map(function (id) { return tree.jstree("get_path", id); });
// remove duplicates
var selected = [];
var uniq = {};
paths.forEach(function (path) {
path.forEach(function (id) {
if (!uniq[id]) {
uniq[id] = true;
selected.push(id);
}
});
});
window.alert(selected.join(","));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.