0
Bootstrap-Treeview을 사용하고 있습니다. 체크 박스가있는 트리가 필요합니다. 그리고 버튼을 누르면 treview 형식으로 서버에 모든 트리를 보내려고합니다. 하지만 treeview에서 실제 데이터를 추출하는 방법을 이해할 수 없습니다. 부트 스트랩 트리 뷰에서 현재 데이터 가져 오기 (개체/json)
<html xmlns="http://www.w3.org/1999/html">
<head>
<link href="bootstrap-treeview.min.css" rel="stylesheet">
<link href="bootstrap.min.css" rel="stylesheet">
<script src="jquery.js"></script>
<script src="bootstrap-treeview.min.js"></script>
<script>
window.onload = function() {
var object = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
nodes: [
{
text: "Grandchild 1"
},
]
},
{
text: "Child 2"
}
]
},
{
text: "Parent 2"
},
];
$('#tree').treeview({
data: object,
showCheckbox: true,
})
.on('nodeSelected', function (event, data) {
console.log('node selected = ' + JSON.stringify(event) + '; data = ' + JSON.stringify(data));
console.log('object =' + JSON.stringify(object));
console.log('tree =' + JSON.stringify($('#tree').data('treeview')));
console.log('tree 2 =' + JSON.stringify($('#tree')));
console.log('tree 3 =' + JSON.stringify($('#tree').treeview(true)));
});
};
</script>
</head>
<body>
<div id="tree">twetwe</div>
</body>
</html>
{"text":"Child 2","nodeId":3,"parentId":0,"selectable":true,"state":{"checked":false,"disabled":false,"expanded":false,"selected":true}}
감사합니다. 그러나, 나는 체크 노드 만 필요하다는 것을 알았다. API에는 getChecked 메소드가 없지만 실제로는 존재합니다. var checked = $ ('# tree'). treeview ('getChecked') - 나를 위해 작동합니다. – cynepnaxa
도움이 되니 기쁩니다. $ ('# tree'). data ('treeview')를 사용하여 콘솔에서 'treeview'객체를보고 객체를 탐색하면 노출 된 모든 메소드를 볼 수 있습니다. – Praym