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

32Re: how to make leaf nodes with TreeView.setDynamicLoad()

Expand Messages
  • ggederer
    Feb 14, 2006
      It ain't pretty; but, here you go:


      <link rel="stylesheet" type="text/css"
      href="<c:url
      value='/scripts/yahooui/treeview/examples/css/folders/tree.css'/>">

      <script type="text/javascript"
      src="<c:url
      value='/scripts/yahooui/treeview/build/YAHOO.js'/>"></script>
      <script type="text/javascript"
      src="<c:url
      value='/scripts/yahooui/treeview/build/treeview.js'/>"></script>

      <!-- Connection Manager source file -->
      <script src="<c:url
      value='/scripts/yahooui/connection/build/connection.js'/>"></script>

      <script type="text/javascript">
      var tree;
      function treeInit() {
      tree = new YAHOO.widget.TreeView("treeDiv1");
      tree.setDynamicLoad(loadDataForNode);

      var root = tree.getRoot();

      var myobj = { label: "mylabel1", id:"myid1" };
      var tmpNode = new YAHOO.widget.TextNode(myobj, root, false);

      myobj = { label: "mylabel2", id:"myid2" } ;
      var tmpNode2 = new YAHOO.widget.TextNode(myobj, tmpNode, false);

      myobj = { label: "mylabel3", id:"myid3" } ;
      var tmpNode3 = new YAHOO.widget.TextNode(myobj, tmpNode, false);

      tree.draw();
      }

      function loadDataForNode(node, onCompleteCallback)
      {
      var id = node.data.id;

      // -- code to get your data, possibly using Connect --
      var responseSuccess = function(o)
      {
      var path;
      var dirs;
      var files;
      //alert('responseSuccess: ' + o.responseXML);
      var xmlDoc = o.responseXML;
      path =
      xmlDoc.getElementsByTagName('path')[0].getAttribute('value');
      //alert(path);
      files = xmlDoc.getElementsByTagName('file');
      dirs = xmlDoc.getElementsByTagName('dir');
      for(var i = 0;i < dirs.length;i++)
      {
      var dirData = dirs[i];
      var name = dirData.getAttribute('name');
      var empty = dirData.getAttribute('empty');

      var myobj = { label: name, id: name + '_id' };
      //alert(node.data.id);

      var tmpNode = new YAHOO.widget.TextNode(myobj, node, false);
      tree.draw();
      }
      }
      var responseFailure = function(o){ alert('responseFailure: ' +
      o.statusText); }
      var callback =
      {
      success:responseSuccess,
      failure:responseFailure,
      };
      var cObj = YAHOO.util.Connect.asyncRequest('POST','<c:url
      value="/fileManager.html"/>',callback,'action=list&path='+id);

      // Be sure to notify the TreeView component when the data load
      is complete
      onCompleteCallback();
      }
      </script>



      --- In ydn-javascript@yahoogroups.com, Scott Walter
      <tx_scottwalter@...> wrote:
      >
      > Can u share an example?
      >
      >
      ----------------------------------------------------------------------------------------------------
      > What's an Intel chip doing in a Mac? A whole lor more that it's ever
      done in a PC.
      >
      > My Digital Life - http://scottwalter.com/blog
      > Pro:Blog - http://scottwalter.com/problog
      >
      > ----- Original Message ----
      > From: ggederer <ggederer@...>
      > To: ydn-javascript@yahoogroups.com
      > Sent: Tuesday, February 14, 2006 4:35:08 PM
      > Subject: [ydn-javascript] how to make leaf nodes with
      TreeView.setDynamicLoad()
      >
      > Hi,
      >
      > I have got a dynamically loding tree working; but, all of the
      > dynamically loaded nodes are expandable. How do I indicate that a
      > dynamically loaded node has no children?
      >
      > Great library!
      >
      > Cheers,
      >
      > Greg
      >
      >
      >
      >
      >
      >
      > SPONSORED LINKS
      > C programming
      language Computer programming
      languages Java programming
      language
      The c programming language
      C programming language
      Concept of programming language

      > YAHOO! GROUPS LINKS
      >
      > Visit your group "ydn-_javascript" on the web.
      > To unsubscribe from this group, send an email to:
      > ydn-_javascript-unsubscribe@yahoogroups.com
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      Service.
      >
    • Show all 10 messages in this topic