Loading ...
Sorry, an error occurred while loading the content.

tasknode example

Expand Messages
  • libraryeva
    Hello, I m not a developer, but I sometimes play one at work. I m trying to use the YUI Treeview example that includes the tasklist checkboxes to create an
    Message 1 of 1 , Oct 4, 2006
    • 0 Attachment
      Hello,

      I'm not a developer, but I sometimes play one at work. I'm trying to
      use the YUI Treeview example that includes the tasklist checkboxes to
      create an interaction design (so it doesn't have to be fully
      functional but it needs to look the way I want). I'm having difficulty
      adjusting the example file ("check.html") to eliminate the random
      generator. So far, I'm able to label the treemenu as I like, but I
      can't get the checkboxes to show. Here's what I've got so far. How
      wrong am I (don't forget...I'm not a developer)?

      <script type="text/javascript" src="js/TaskNode.js"></script>

      <div id="content">
      <form name="mainForm" action="javscript:;">
      <div class="newsItem">
      <h3>Search for...</h3>
      <p>
      <input type="text" size="65%";/>
      <input type="reset" value="Go";/>
      More search options...<br>
      <input type="radio" value="everything" checked
      name="searchrealm";/>
      Everything
      <input type="radio" value="federated" name="searchrealm";/>
      Books and articles
      <input type="radio" value="ejournals" name="searchrealm";/>
      Journal/Magazine titles
      <input type="radio" value="sitesearch" name="searchrealm";/>
      Library site </p>
      <div id="expandcontractdiv">
      <a href="javascript:tree.expandAll()">Expand all</a>
      <a href="javascript:tree.collapseAll()">Collapse all</a>
      <a href="javascript:checkAll()">Check all</a>
      <a href="javascript:uncheckAll()">Uncheck all</a>
      </div>
      <div id="treeDiv1"></div>
      </div>
      </form>
      </div>
      </div>
      </div>
      <!--
      <input type="button" id="showButton" />
      -->


      <script type="text/javascript">

      var tree;
      var nodes = new Array();
      var nodeIndex;

      function treeInit() {
      tree = new YAHOO.widget.TreeView("treeDiv1");
      var root = tree.getRoot();
      var tmpNode = new YAHOO.widget.TextNode("Books and articles", root,
      false);
      var tmpNode2 = new YAHOO.widget.TextNode("Catalog", tmpNode, false);
      var tmpNode3 = new YAHOO.widget.TextNode("eResources", tmpNode, false);
      var tmpNode4 = new YAHOO.widget.TextNode("Virtual Research
      Library", tmpNode, false);
      var tmpNode5 = new YAHOO.widget.TextNode("Library site", root, false);
      var tmpNode6 = new YAHOO.widget.TextNode("Help", tmpNode5, false);

      tree.draw();
      tree.checkClickEvent.subscribe(onCheckClick);
      }

      var callback = null;

      function buildTasknode(node) {
      if (node.depth < 5) {
      tmpNode = new YAHOO.widget.TaskNode(node.label + "-" + i, node,
      false, true);
      }
      }

      function onCheckClick(eventType, args, tree) {
      var node = args[0];
      //function onCheckClick(eventType, args, tree) {
      //var node = this;
      //YAHOO.log(node.label + " check was clicked, new state: " +
      // node.checkState);
      }

      function showTreeState() {
      var out = [];
      for (var i in tree._nodes) {
      var n = tree._nodes[i];
      if (n && "undefined" != typeof n.checkState) {
      out.push(n.data + ": " + n.checkState);
      }
      }

      alert(out.join("\n"));
      }

      function checkAll() {
      var topNodes = tree.getRoot().children;
      for(var i = 0; i <= topNodes.length; ++i) {
      topNodes[i].check();
      }
      }

      function uncheckAll() {
      var topNodes = tree.getRoot().children;
      for(var i = 0; i <= topNodes.length; ++i) {
      topNodes[i].uncheck();
      }
      }

      function showJSON() {
      alert(JSON.stringify(tree._nodes));
      }

      //YAHOO.util.Event.on("showButton", "click", showTreeState);
      //YAHOO.util.Event.on("showButton", "click", showJSON);

      </script>

      thanks,
      Eva
    Your message has been successfully submitted and would be delivered to recipients shortly.