JSFiddle - React, Tailwind, and code Playground
by matox
JavaScript
function getSelected(tree, type, group, entity)
{
switch(type)
{
case "group": $("#" + tree + " .group").each(function(){
if($(this).hasClass("jstree-checked"))
{
return '[{"group" : "'+ $(this).attr("name") +'", "entity" : "*"}]';
}
else if($(this).hasClass("jstree-undetermined"))
{
$("#" + tree).jstree("open_node", $(this));
$("#" + tree).jstree("close_node", $(this));
return '[{"group" : "'+ $(this).attr("name") +'", "entity" : "'+ getSelected(tree, "entity", $(this).attr("name")) +'"}]';
}
else
{
return '';
}
});
break;
case "entity": $("#" + tree + " [name='" + group + "'].group .entity").each(function(){
if($(this).hasClass("jstree-checked"))
{
return '[{"name" : "'+ $(this).attr("name") +'", "data" : "*"}]';
}
else if($(this).hasClass("jstree-undetermined"))
{
$("#" + tree).jstree("open_node", $(this));
$("#" + tree).jstree("close_all");
return '[{"name" : "'+ $(this).attr("name") +'", "data" : "'+ getSelected(tree, "data", group, $(this).attr("name")) +'"}]';
}
else
{
return '';
}
});
break;
case "data": $("#" + tree + " [name='" + group + "'].group [name='" + entity + "'].entity .data").each(function(){
if($(this).hasClass("jstree-checked") || $(this).hasClass("jstree-undetermined"))
{
return $(this).attr("name");
}
else
{
return '';
}
});
break;
}
}