release/0.1.0.244 #1
5
bbtreeview.min.js
vendored
5
bbtreeview.min.js
vendored
File diff suppressed because one or more lines are too long
@ -31,26 +31,29 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
||||||
<p>Create demo treeview with checkboxes and selection enabled</p>
|
<p>Create demo treeview</p>
|
||||||
<button onclick="CreateTreeview()">Create Treeview</button>
|
<button onclick="CreateTreeview(1)">Create Treeview (Checkbox and Selection)</button>
|
||||||
|
<button onclick="CreateTreeview(2)">Create Treeview (Checkbox, Hide Selection, Check Parent if Any Child Checked)</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="panel">
|
||||||
|
|
||||||
|
<p>Load sample nodes</p>
|
||||||
|
<button onclick="LoadTreeview()">Load Treeview</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
||||||
<p>Clear treeview</p>
|
<p>Clear treeview</p>
|
||||||
<button onclick="ClearTreeview()">Clear Treeview</button>
|
<p>
|
||||||
|
<button onclick="ClearTreeview()">Clear Treeview</button>
|
||||||
</div>
|
<button onclick="RemoveTreeNode()">Remove Treenode</button>
|
||||||
<div class="panel">
|
</p>
|
||||||
|
|
||||||
<p>Remove the "Program Files" treenode</p>
|
|
||||||
<button onclick="RemoveTreeNode()">Remove Treenode</button>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
||||||
<p>Find a treenode</p>
|
<p>Find a treenode</p>
|
||||||
<p>
|
|
||||||
<button onclick="FindTreeNode()">Find Treenode By ID</button>
|
<button onclick="FindTreeNode()">Find Treenode By ID</button>
|
||||||
<button onclick="FindTreeNodesByName()">Find Treenode By Name</button>
|
<button onclick="FindTreeNodesByName()">Find Treenode By Name</button>
|
||||||
<button onclick="FindTreeNodesByValue()">Find Treenode By Value</button>
|
<button onclick="FindTreeNodesByValue()">Find Treenode By Value</button>
|
||||||
@ -111,16 +114,33 @@ body {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var treeview1 = new BBTreeview({
|
function CreateTreeview(value){
|
||||||
ID: "#treeview1",
|
switch (value) {
|
||||||
ShowCheckbox: true,
|
case 1:
|
||||||
ShowSelection: true
|
window.treeview1 = new BBTreeview({
|
||||||
});
|
ID: "#treeview1",
|
||||||
|
ShowCheckbox: true,
|
||||||
|
ShowSelection: true
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
window.treeview1 = new BBTreeview({
|
||||||
|
ID: "#treeview1",
|
||||||
|
ShowCheckbox: true,
|
||||||
|
ShowSelection: false,
|
||||||
|
CheckParentAny: true
|
||||||
|
});
|
||||||
|
|
||||||
function CreateTreeview(){
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
treeview1.AddItem({
|
function LoadTreeview(){
|
||||||
|
|
||||||
|
window.treeview1.AddItem({
|
||||||
ID: "root",
|
ID: "root",
|
||||||
Name: "C:\\"
|
Name: "C:\\"
|
||||||
});
|
});
|
||||||
@ -135,7 +155,7 @@ function CreateTreeview(){
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (let i=0; i<folders1.length; i++) {
|
for (let i=0; i<folders1.length; i++) {
|
||||||
treeview1.AddItem({
|
window.treeview1.AddItem({
|
||||||
ID: "0_" + i,
|
ID: "0_" + i,
|
||||||
ParentID: "root",
|
ParentID: "root",
|
||||||
Name: folders1[i],
|
Name: folders1[i],
|
||||||
@ -152,7 +172,7 @@ function CreateTreeview(){
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (let i=0; i<folders12.length; i++) {
|
for (let i=0; i<folders12.length; i++) {
|
||||||
treeview1.AddItem({
|
window.treeview1.AddItem({
|
||||||
ID: "0_2_" + i,
|
ID: "0_2_" + i,
|
||||||
ParentID: "0_2",
|
ParentID: "0_2",
|
||||||
Name: folders12[i],
|
Name: folders12[i],
|
||||||
@ -166,7 +186,7 @@ function CreateTreeview(){
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (let i=0; i<folders13.length; i++) {
|
for (let i=0; i<folders13.length; i++) {
|
||||||
treeview1.AddItem({
|
window.treeview1.AddItem({
|
||||||
ID: "0_3_" + i,
|
ID: "0_3_" + i,
|
||||||
ParentID: "0_3",
|
ParentID: "0_3",
|
||||||
Name: folders13[i],
|
Name: folders13[i],
|
||||||
@ -181,7 +201,7 @@ function CreateTreeview(){
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (let i=0; i<folders15.length; i++) {
|
for (let i=0; i<folders15.length; i++) {
|
||||||
treeview1.AddItem({
|
window.treeview1.AddItem({
|
||||||
ID: "0_5_" + i,
|
ID: "0_5_" + i,
|
||||||
ParentID: "0_5",
|
ParentID: "0_5",
|
||||||
Name: folders15[i],
|
Name: folders15[i],
|
||||||
@ -189,7 +209,7 @@ function CreateTreeview(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
treeview1.AddItem({
|
window.treeview1.AddItem({
|
||||||
ID: "0_2_3_0",
|
ID: "0_2_3_0",
|
||||||
ParentID: "0_2_3",
|
ParentID: "0_2_3",
|
||||||
Name: "en-GB",
|
Name: "en-GB",
|
||||||
@ -199,15 +219,15 @@ function CreateTreeview(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ClearTreeview() {
|
function ClearTreeview() {
|
||||||
treeview1.Clear();
|
window.treeview1.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveTreeNode() {
|
function RemoveTreeNode() {
|
||||||
treeview1.Remove("0_2");
|
window.treeview1.Remove("0_2");
|
||||||
}
|
}
|
||||||
|
|
||||||
function FindTreeNode() {
|
function FindTreeNode() {
|
||||||
let treenode = treeview1.Find("0_5");
|
let treenode = window.treeview1.Find("0_5");
|
||||||
|
|
||||||
console.log(treenode);
|
console.log(treenode);
|
||||||
|
|
||||||
@ -215,7 +235,7 @@ function FindTreeNode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function FindTreeNodesByName() {
|
function FindTreeNodesByName() {
|
||||||
let treenodes = treeview1.FindByName("Common Files");
|
let treenodes = window.treeview1.FindByName("Common Files");
|
||||||
|
|
||||||
console.log(treenodes);
|
console.log(treenodes);
|
||||||
|
|
||||||
@ -223,7 +243,7 @@ function FindTreeNodesByName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function FindTreeNodesByValue() {
|
function FindTreeNodesByValue() {
|
||||||
let treenodes = treeview1.FindByValue("Internet Explorer");
|
let treenodes = window.treeview1.FindByValue("Internet Explorer");
|
||||||
|
|
||||||
console.log(treenodes);
|
console.log(treenodes);
|
||||||
|
|
||||||
@ -231,7 +251,7 @@ function FindTreeNodesByValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GetSelectedTreeNode() {
|
function GetSelectedTreeNode() {
|
||||||
let treenode = treeview1.GetSelectedNode();
|
let treenode = window.treeview1.GetSelectedNode();
|
||||||
|
|
||||||
console.log(treenode);
|
console.log(treenode);
|
||||||
|
|
||||||
@ -239,7 +259,7 @@ function GetSelectedTreeNode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GetCheckedTreeNodes() {
|
function GetCheckedTreeNodes() {
|
||||||
let treenodes = treeview1.GetCheckedNodes();
|
let treenodes = window.treeview1.GetCheckedNodes();
|
||||||
|
|
||||||
console.log(treenodes);
|
console.log(treenodes);
|
||||||
|
|
||||||
@ -247,7 +267,7 @@ function GetCheckedTreeNodes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GetAllTreeNodes() {
|
function GetAllTreeNodes() {
|
||||||
let treenodes = treeview1.GetAllNodes();
|
let treenodes = window.treeview1.GetAllNodes();
|
||||||
|
|
||||||
console.log(treenodes);
|
console.log(treenodes);
|
||||||
|
|
||||||
@ -255,7 +275,7 @@ function GetAllTreeNodes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GetCheckedValues() {
|
function GetCheckedValues() {
|
||||||
let treenodes = treeview1.GetCheckedValues();
|
let treenodes = window.treeview1.GetCheckedValues();
|
||||||
|
|
||||||
console.log(treenodes);
|
console.log(treenodes);
|
||||||
|
|
||||||
@ -263,19 +283,19 @@ function GetCheckedValues() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CollapseAll() {
|
function CollapseAll() {
|
||||||
treeview1.CollapseAll();
|
window.treeview1.CollapseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExpandAll() {
|
function ExpandAll() {
|
||||||
treeview1.ExpandAll();
|
window.treeview1.ExpandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckAll() {
|
function CheckAll() {
|
||||||
treeview1.CheckAll(true);
|
window.treeview1.CheckAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UncheckAll() {
|
function UncheckAll() {
|
||||||
treeview1.CheckAll(false);
|
window.treeview1.CheckAll(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* BBTreeview
|
* BBTreeview
|
||||||
* @version v0.1.0.223 (2023/09/08 2027)
|
* @version v0.1.0.244 (2023/09/11 2327)
|
||||||
*/
|
*/
|
||||||
function BBTreeview(options)
|
function BBTreeview(options)
|
||||||
{
|
{
|
||||||
@ -64,7 +64,8 @@ BBTreeview.prototype.Default = function() {
|
|||||||
TreeviewOptions: {
|
TreeviewOptions: {
|
||||||
ID: null,
|
ID: null,
|
||||||
ShowCheckbox: false,
|
ShowCheckbox: false,
|
||||||
ShowSelection: true
|
ShowSelection: true,
|
||||||
|
CheckParentAny: false
|
||||||
},
|
},
|
||||||
TreeNodeOptions: {
|
TreeNodeOptions: {
|
||||||
ID: null,
|
ID: null,
|
||||||
@ -116,6 +117,11 @@ BBTreeview.prototype.CheckAll = function(value) {
|
|||||||
BBTreeview.prototype.Find = function(id) {
|
BBTreeview.prototype.Find = function(id) {
|
||||||
const a = this;
|
const a = this;
|
||||||
|
|
||||||
|
if (a.Container == null){
|
||||||
|
console.log("BBTreeview container not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const node = a.Container.querySelectorAll("li[data-bbtv-id='" + id + "']");
|
const node = a.Container.querySelectorAll("li[data-bbtv-id='" + id + "']");
|
||||||
if (node.length <= 0) {
|
if (node.length <= 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* BBTreeview
|
* BBTreeview
|
||||||
* @version v0.1.0.223 (2023/09/08 2027)
|
* @version v0.1.0.244 (2023/09/11 2327)
|
||||||
*/
|
*/
|
||||||
function BBTreeviewNode(treeview)
|
function BBTreeviewNode(treeview)
|
||||||
{
|
{
|
||||||
@ -45,13 +45,20 @@ BBTreeviewNode.prototype.Check = function(value) {
|
|||||||
// Update parent state
|
// Update parent state
|
||||||
if (a.GetParentNode() != null) {
|
if (a.GetParentNode() != null) {
|
||||||
let uncheckedCount = 0;
|
let uncheckedCount = 0;
|
||||||
a.GetParentNode().querySelectorAll("li").forEach(function(e) {
|
|
||||||
if (e.classList.contains("x")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uncheckedCount++;
|
if (a.Treeview.Options.CheckParentAny) {
|
||||||
});
|
if (a.GetParentNode().querySelectorAll("li.x").length > 0) {
|
||||||
|
uncheckedCount = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a.GetParentNode().querySelectorAll("li").forEach(function(e) {
|
||||||
|
if (e.classList.contains("x")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uncheckedCount++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
a.setCheckbox(a.GetParentNode(), (uncheckedCount <= 0));
|
a.setCheckbox(a.GetParentNode(), (uncheckedCount <= 0));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user