我得到了这个问题,即时通讯工作与asp和jstree复选框插件,我需要得到比选定的所有节点(父母与他的孩子),首选完整路径阵列然后分裂它,因为我需要做一个数据库搜索,我需要父母和孩子。ASP.NET jstree复选框得到所有选定的节点和子节点
这是我的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="jstree-bootstrap-theme-master/dist/libs/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" />
<link href="jstree-bootstrap-theme-master/dist/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="jstree-bootstrap-theme-master/dist/themes/proton/style.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="jstree-bootstrap-theme-master/dist/libs/bootstrap/js/bootstrap.min.js"></script>
<script src="jstree-bootstrap-theme-master/dist/jstree.min.js"></script>
</head>
<body>
<div id="container">
<ul>
<li>Root node
<ul>
<li id="child_node">Child node</li>
</ul>
</li>
</ul>
</div>
<button type="button" class="btn btn-primary" id="getChecked">Botón normal</button>
<script type="text/javascript">
$('#container').jstree({
'plugins': ["wholerow", "checkbox"],
'core': {
'data': [{
"text": "RRRAAAA",
"children": [
{
"text": "S1",
"icon": "glyphicon glyphicon-chevron-right",
"state": {
"selected": false
}
},
{
"text": "S2",
"icon": "glyphicon glyphicon-chevron-right"
},
{
"text": "A2",
"icon": "glyphicon glyphicon-chevron-right"
},
{
"text": "A2",
"icon": "glyphicon glyphicon-chevron-right"
},
{
"text": "F",
"icon": "glyphicon glyphicon-chevron-right"
}]
}],
'themes': {
'name': 'proton',
'responsive': true
}
}
}).on('select_node.jstree', function (e, data) {
var i, j, nid;
for (i = 0, j = data.selected.length; i < j; i++) {
nid = data.instance.get_node(data.selected[i]).id;
alert(nid);
}
});
$(function() {
$("#getChecked").click(function() {
$("#tree").jstree("get_checked", null, true).each(function (i, e) {
console.log($(this).attr("id"));
alert($(this).attr("id"));
});
});
});
</script>
</body>
</html>
它不工作:( – 2016-04-11 14:02:47