我在我的代碼中使用dynaTree http://wwwendt.de/tech/dynatree/index.html來顯示2級樹。此樹顯示在selectMode = 3
和checkboxes
中,當用戶選中節點複選框時,其父代會變爲gray mode
。如何讀取部分選定子節點的父節點
在下一個階段,當用戶點擊一個按鈕時,我將所有選定的節點發送到服務器進行處理。 我想要做的是發送所有gray mode
複選框。
我該如何實現這個目標?
編輯: 這是所有的代碼,你需要
<html>
<head>
<link type="text/css" href="../css/ui.dynatree.css" rel="stylesheet">
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="../js/jquery.dynatree.min.js"></script>
<script type="text/javascript">
var treeData = [
{ key: "key1", title: "Text 1" },
{ key: "Key2", title: "Text 2",
children: [
{ key: "Key2_1", title: "Text 2_1" },
{ key: "Key2_2", title: "Text 2_2" },
]
},
];
$(function() {
$("#tree").dynatree({
checkbox: true,
selectMode: 3,
children: treeData,
imagePath: "../images/Tree/",
onSelect: function (select, node) {
var selKeys = $.map(node.tree.getSelectedNodes(), function (node) {
return node.data.key;
});
$('#textField').val(selKeys.join(", "));
}
});
});
</script>
</head>
<body>
<div id="tree"></div>
<input type="text" id="textField" value="" /><input type="button" id="button" onclick="alert($('#textField').val())" value="Send" />
</body>
</html>
當選擇Key2_1
,Key2
去gray state
,你會看到Key2_1
被添加到textField
文本框,我想有鍵2在textField
場也是如此。
注:選擇的Key2_1
和Key2_2
兩個子節點也將選擇父(key_2),但不能當它在gray mode
請上傳您所使用的代碼。 – lucuma