I have a jstree with check boxes. When I select a node and click on button then I am geting the name of that node. But now I would like to allow multiple selection so that I have assigned check box to jstree each elements. No how can I get the c=value of selected nodes. Also I want to allow search in that but I don't know how to do it.
I have enabled ssearch plugin. Here is my code
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style>
html { margin:0; padding:0; font-size:62.5%; }
body { max-width:300px; min-width:100px; padding:20px 10px; font-size:14px; font-size:1.4em; }
h1 { font-size:1.8em; }
.demo { overflow:auto; border:1px solid silver; min-height:100px; }
</style>
<link rel="stylesheet" href="style.min.css" />
</head>
<body>
<div id="frmt" class="demo"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jstree.min.js"></script>
<button>>></button>
<script>
$('#html').jstree();
$('#frmt').jstree({
'core': {
'data':[{"id":"NODE 1","text":"node 1","children":[{"id","node 2","text":"node2"}]}]
},
"checkbox" : {
"whole_node" : false,
"keep_selected_style" : true,
"three_state" : true,
"tie_selection" : false
}, "search" : {
"fuzzy" : true
},"plugins" : [ "checkbox", "search", "state", "wholerow", "types", "selectopens" ]
});
$('#frmt').on("changed.jstree", function (e, data) {
console.log(data.selected);
});
$('button').on('click', function () {
alert($('#frmt').jstree("get_selected"));
});
</script>
</body>
</html>
You can get it by
alert($('#frmt').jstree("get_checked"));