release/0.1.0.244 #1
@ -65,7 +65,7 @@ BBTreeview.prototype.Default = function() {
 | 
			
		||||
      ID: null,
 | 
			
		||||
      ShowCheckbox: false,
 | 
			
		||||
      ShowSelection: true,
 | 
			
		||||
      CheckParentAny: false
 | 
			
		||||
      EnablePullUp: false
 | 
			
		||||
    },
 | 
			
		||||
    TreeNodeOptions: {
 | 
			
		||||
      ID: null,
 | 
			
		||||
@ -217,6 +217,18 @@ BBTreeview.prototype.GetCheckedValues = function() {
 | 
			
		||||
  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() {
 | 
			
		||||
  const a = this;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								bbtreeview.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								bbtreeview.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -43,24 +43,37 @@ BBTreeviewNode.prototype.Check = function(value) {
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // Update parent state
 | 
			
		||||
  if (a.GetParentNode() != null) {
 | 
			
		||||
    let uncheckedCount = 0;
 | 
			
		||||
  let parentNode = a.GetParentNode();
 | 
			
		||||
  if (parentNode == null) {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    if (a.Treeview.Options.CheckParentAny) {
 | 
			
		||||
      if (a.GetParentNode().querySelectorAll("li.x").length > 0) {
 | 
			
		||||
        uncheckedCount = 0;
 | 
			
		||||
  // 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 {
 | 
			
		||||
      a.GetParentNode().querySelectorAll("li").forEach(function(e) {
 | 
			
		||||
    let uncheckedCount = 0;
 | 
			
		||||
 | 
			
		||||
    parentNode.querySelectorAll("li").forEach(function(e) {
 | 
			
		||||
      if (e.classList.contains("x")) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      uncheckedCount++;
 | 
			
		||||
    });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    a.setCheckbox(a.GetParentNode(), (uncheckedCount <= 0));
 | 
			
		||||
    a.setCheckbox(parentNode, (uncheckedCount <= 0));
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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="src/bbtreeview.css" rel="stylesheet" /> -->
 | 
			
		||||
  <!-- <script src="src/bbtreeview.js"></script> -->
 | 
			
		||||
  <!-- <script src="src/bbtreeviewnode.js"></script> -->
 | 
			
		||||
 | 
			
		||||
  <link href="bbtreeview.min.css" rel="stylesheet" />
 | 
			
		||||
  <!-- <script src="bbtreeview.js"></script> -->
 | 
			
		||||
  <!-- <script src="bbtreeviewnode.js"></script> -->
 | 
			
		||||
  <script src="bbtreeview.min.js"></script>
 | 
			
		||||
 | 
			
		||||
  <title></title>
 | 
			
		||||
@ -32,8 +31,9 @@
 | 
			
		||||
    <div class="panel">
 | 
			
		||||
 | 
			
		||||
      <p>Create demo treeview</p>
 | 
			
		||||
      <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>
 | 
			
		||||
      <p><button onclick="CreateTreeview(1)">Create Treeview (Checkbox and Selection)</button></p>
 | 
			
		||||
      <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 class="panel">
 | 
			
		||||
@ -67,6 +67,7 @@
 | 
			
		||||
        <button onclick="GetAllTreeNodes()">Get All Treenodes</button>
 | 
			
		||||
        <button onclick="GetSelectedTreeNode()">Get Highlighted Treenode</button>
 | 
			
		||||
        <button onclick="GetCheckedTreeNodes()">Get Checked Treenodes</button>
 | 
			
		||||
        <button onclick="GetCheckedTags()">Get Checked Treenode Tags</button>
 | 
			
		||||
      </p>
 | 
			
		||||
      <p>
 | 
			
		||||
        <button onclick="GetCheckedValues()">Get Checked Values</button>
 | 
			
		||||
@ -114,6 +115,10 @@ body {
 | 
			
		||||
 | 
			
		||||
  <script>
 | 
			
		||||
 | 
			
		||||
CreateTreeview(1);
 | 
			
		||||
LoadTreeview();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function CreateTreeview(value){
 | 
			
		||||
  switch (value) {
 | 
			
		||||
    case 1:
 | 
			
		||||
@ -129,7 +134,16 @@ function CreateTreeview(value){
 | 
			
		||||
        ID: "#treeview1",
 | 
			
		||||
        ShowCheckbox: true,
 | 
			
		||||
        ShowSelection: false,
 | 
			
		||||
        CheckParentAny: true
 | 
			
		||||
        EnablePullUp: true
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      break;
 | 
			
		||||
    case 3:
 | 
			
		||||
      window.treeview1 = new BBTreeview({
 | 
			
		||||
        ID: "#treeview1",
 | 
			
		||||
        ShowCheckbox: false,
 | 
			
		||||
        ShowSelection: true,
 | 
			
		||||
        EnablePullUp: false
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      break;
 | 
			
		||||
@ -266,6 +280,14 @@ function GetCheckedTreeNodes() {
 | 
			
		||||
  alert(JSON.stringify(treenodes));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function GetCheckedTags() {
 | 
			
		||||
  let treenodes = window.treeview1.GetCheckedTags();
 | 
			
		||||
 | 
			
		||||
  console.log(treenodes);
 | 
			
		||||
 | 
			
		||||
  alert(JSON.stringify(treenodes));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function GetAllTreeNodes() {
 | 
			
		||||
  let treenodes = window.treeview1.GetAllNodes();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user