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

Dynamic Tree Loading - loadNodeData custom arguments

Expand Messages
  • ray.adate
    I m trying to use dynamic Tree view. On loading the child nodes, I m making an AJAX call to retrieve data from database. I m currently hardcoding the Id for
    Message 1 of 3 , Jun 29 9:07 AM
    • 0 Attachment
      I'm trying to use dynamic Tree view. On loading the child nodes, I'm
      making an AJAX call to retrieve data from database.

      I'm currently hardcoding the Id for which I need to retrieve data by
      AJAX call. I want top pass this Id as an argument to loadNodeData or
      any other work around to not hardcode this id, but retrieve from the
      list.

      Follwing is the code I'm using. Any help would be great.

      Thanks in advance
      Ray.

      ===============================
      function treeInit() {
      tree = new YAHOO.widget.TreeView("myTree");
      var root = tree.getRoot();

      <c:forEach items="${elementList}" var="myElement" varStatus="status">
      var myobj = { label: "${myElement.name}",
      var tmpNode = new YAHOO.widget.TextNode(myobj , root, false);

      //turn dynamic loading on for the node:
      tmpNode.setDynamicLoad(this.loadNodeData 1);

      </c:forEach>
      tree.draw();
      }

      function loadNodeData(node, fnLoadComplete) {
      // Currently hardcoiding the element ID
      var elementId = 10;

      // AJAX Call - retrieve data for a particular elementId
      retriveDataFromServer(elementId);

      fnLoadComplete();
      }

      ===============================
    • Adam Moore
      ... Ray, store the id in the data object you are using to create the node. I ve modified the code above to show how it might look. -Adam
      Message 2 of 3 , Jun 29 11:19 AM
      • 0 Attachment
        On Thu, Jun 29, 2006 at 04:07:26PM -0000, ray.adate wrote:
        > I'm trying to use dynamic Tree view. On loading the child nodes, I'm
        > making an AJAX call to retrieve data from database.
        >
        > I'm currently hardcoding the Id for which I need to retrieve data by
        > AJAX call. I want top pass this Id as an argument to loadNodeData or
        > any other work around to not hardcode this id, but retrieve from the
        > list.
        >
        > Follwing is the code I'm using. Any help would be great.
        >
        > Thanks in advance
        > Ray.
        >
        > ===============================
        > function treeInit() {
        > tree = new YAHOO.widget.TreeView("myTree");
        > var root = tree.getRoot();
        >
        > <c:forEach items="${elementList}" var="myElement" varStatus="status">
        > var myobj = { label: "${myelement.name}", id: "${myelement.id}" };
        > var tmpNode = new YAHOO.widget.TextNode(myobj , root, false);
        >
        > //turn dynamic loading on for the node:
        > tmpNode.setDynamicLoad(this.loadNodeData 1);
        >
        > </c:forEach>
        > tree.draw();
        > }
        >
        > function loadNodeData(node, fnLoadComplete) {
        > // Currently hardcoiding the element ID
        > // var elementId = 10;
        > var elementId = node.data.id;
        >
        > // AJAX Call - retrieve data for a particular elementId
        > retriveDataFromServer(elementId);
        >
        > fnLoadComplete();
        > }

        Ray, store the id in the data object you are using to create the node.
        I've modified the code above to show how it might look.

        -Adam
      • ray.adate
        Thanks so much Adam. That worked :) - Roopa ... ${myelement.id} };
        Message 3 of 3 , Jun 29 12:07 PM
        • 0 Attachment
          Thanks so much Adam. That worked :)

          - Roopa
          --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@...> wrote:
          >
          > On Thu, Jun 29, 2006 at 04:07:26PM -0000, ray.adate wrote:
          > > I'm trying to use dynamic Tree view. On loading the child nodes, I'm
          > > making an AJAX call to retrieve data from database.
          > >
          > > I'm currently hardcoding the Id for which I need to retrieve data by
          > > AJAX call. I want top pass this Id as an argument to loadNodeData or
          > > any other work around to not hardcode this id, but retrieve from the
          > > list.
          > >
          > > Follwing is the code I'm using. Any help would be great.
          > >
          > > Thanks in advance
          > > Ray.
          > >
          > > ===============================
          > > function treeInit() {
          > > tree = new YAHOO.widget.TreeView("myTree");
          > > var root = tree.getRoot();
          > >
          > > <c:forEach items="${elementList}" var="myElement" varStatus="status">
          > > var myobj = { label: "${myelement.name}", id:
          "${myelement.id}" };
          > > var tmpNode = new YAHOO.widget.TextNode(myobj , root, false);
          > >
          > > //turn dynamic loading on for the node:
          > > tmpNode.setDynamicLoad(this.loadNodeData 1);
          > >
          > > </c:forEach>
          > > tree.draw();
          > > }
          > >
          > > function loadNodeData(node, fnLoadComplete) {
          > > // Currently hardcoiding the element ID
          > > // var elementId = 10;
          > > var elementId = node.data.id;
          > >
          > > // AJAX Call - retrieve data for a particular elementId
          > > retriveDataFromServer(elementId);
          > >
          > > fnLoadComplete();
          > > }
          >
          > Ray, store the id in the data object you are using to create the node.
          > I've modified the code above to show how it might look.
          >
          > -Adam
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.