release/0.1.0.244 #1

Merged
Ray merged 2 commits from release/0.1.0.244 into master 2023-09-27 21:03:27 +00:00
4 changed files with 70 additions and 20 deletions
Showing only changes of commit 7023162ba9 - Show all commits

View File

@ -65,7 +65,7 @@ BBTreeview.prototype.Default = function() {
ID: null, ID: null,
ShowCheckbox: false, ShowCheckbox: false,
ShowSelection: true, ShowSelection: true,
CheckParentAny: false EnablePullUp: false
}, },
TreeNodeOptions: { TreeNodeOptions: {
ID: null, ID: null,
@ -217,6 +217,18 @@ BBTreeview.prototype.GetCheckedValues = function() {
return response; return response;
}; };
BBTreeview.prototype.GetCheckedTags = function() {
const a = this;
let response = [];
a.GetCheckedNodes().map(function(e) {
response.push(e.Tag);
});
return response;
};
BBTreeview.prototype.GetSelectedNode = function() { BBTreeview.prototype.GetSelectedNode = function() {
const a = this; const a = this;

3
bbtreeview.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -43,24 +43,37 @@ BBTreeviewNode.prototype.Check = function(value) {
}); });
// Update parent state // Update parent state
if (a.GetParentNode() != null) { let parentNode = a.GetParentNode();
if (parentNode == null) {
return;
}
// Handle pull-ups
if (a.Treeview.Options.EnablePullUp) {
while (true) {
const parentChecked = (parentNode.querySelectorAll("li.x").length > 0);
a.setCheckbox(parentNode, parentChecked);
parentNode = a.Treeview.getNode(parentNode);
parentNode = parentNode.GetParentNode();
if (parentNode == null) {
break;
}
}
} else {
let uncheckedCount = 0; let uncheckedCount = 0;
if (a.Treeview.Options.CheckParentAny) { parentNode.querySelectorAll("li").forEach(function(e) {
if (a.GetParentNode().querySelectorAll("li.x").length > 0) { if (e.classList.contains("x")) {
uncheckedCount = 0; return;
} }
} else {
a.GetParentNode().querySelectorAll("li").forEach(function(e) {
if (e.classList.contains("x")) {
return;
}
uncheckedCount++; uncheckedCount++;
}); });
}
a.setCheckbox(a.GetParentNode(), (uncheckedCount <= 0)); a.setCheckbox(parentNode, (uncheckedCount <= 0));
} }
}; };

View File

@ -11,10 +11,9 @@
<!-- <link href="http://cdn.hiimray.co.uk/8206c600-707c-469e-8d49-a76ae35782af/bootstrap/5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> --> <!-- <link href="http://cdn.hiimray.co.uk/8206c600-707c-469e-8d49-a76ae35782af/bootstrap/5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> -->
<!-- <link href="src/bbtreeview.css" rel="stylesheet" /> --> <!-- <link href="src/bbtreeview.css" rel="stylesheet" /> -->
<!-- <script src="src/bbtreeview.js"></script> -->
<!-- <script src="src/bbtreeviewnode.js"></script> -->
<link href="bbtreeview.min.css" rel="stylesheet" /> <link href="bbtreeview.min.css" rel="stylesheet" />
<!-- <script src="bbtreeview.js"></script> -->
<!-- <script src="bbtreeviewnode.js"></script> -->
<script src="bbtreeview.min.js"></script> <script src="bbtreeview.min.js"></script>
<title></title> <title></title>
@ -32,8 +31,9 @@
<div class="panel"> <div class="panel">
<p>Create demo treeview</p> <p>Create demo treeview</p>
<button onclick="CreateTreeview(1)">Create Treeview (Checkbox and Selection)</button> <p><button onclick="CreateTreeview(1)">Create Treeview (Checkbox and Selection)</button></p>
<button onclick="CreateTreeview(2)">Create Treeview (Checkbox, Hide Selection, Check Parent if Any Child Checked)</button> <p><button onclick="CreateTreeview(2)">Create Treeview (Checkbox, Hide Selection, Enable Pull-Ups)</button></p>
<p><button onclick="CreateTreeview(3)">Create Treeview (No Checkbox, Selection)</button></p>
</div> </div>
<div class="panel"> <div class="panel">
@ -67,6 +67,7 @@
<button onclick="GetAllTreeNodes()">Get All Treenodes</button> <button onclick="GetAllTreeNodes()">Get All Treenodes</button>
<button onclick="GetSelectedTreeNode()">Get Highlighted Treenode</button> <button onclick="GetSelectedTreeNode()">Get Highlighted Treenode</button>
<button onclick="GetCheckedTreeNodes()">Get Checked Treenodes</button> <button onclick="GetCheckedTreeNodes()">Get Checked Treenodes</button>
<button onclick="GetCheckedTags()">Get Checked Treenode Tags</button>
</p> </p>
<p> <p>
<button onclick="GetCheckedValues()">Get Checked Values</button> <button onclick="GetCheckedValues()">Get Checked Values</button>
@ -114,6 +115,10 @@ body {
<script> <script>
CreateTreeview(1);
LoadTreeview();
function CreateTreeview(value){ function CreateTreeview(value){
switch (value) { switch (value) {
case 1: case 1:
@ -129,7 +134,16 @@ function CreateTreeview(value){
ID: "#treeview1", ID: "#treeview1",
ShowCheckbox: true, ShowCheckbox: true,
ShowSelection: false, ShowSelection: false,
CheckParentAny: true EnablePullUp: true
});
break;
case 3:
window.treeview1 = new BBTreeview({
ID: "#treeview1",
ShowCheckbox: false,
ShowSelection: true,
EnablePullUp: false
}); });
break; break;
@ -266,6 +280,14 @@ function GetCheckedTreeNodes() {
alert(JSON.stringify(treenodes)); alert(JSON.stringify(treenodes));
} }
function GetCheckedTags() {
let treenodes = window.treeview1.GetCheckedTags();
console.log(treenodes);
alert(JSON.stringify(treenodes));
}
function GetAllTreeNodes() { function GetAllTreeNodes() {
let treenodes = window.treeview1.GetAllNodes(); let treenodes = window.treeview1.GetAllNodes();