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

Re: Dynamic Tree Loading - loadNodeData custom arguments

Expand Messages
  • ray.adate
    Thanks so much Adam. That worked :) - Roopa ... ${myelement.id} };
    Message 1 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.