Search the web
Sign In
New User? Sign Up
ydn-javascript · Yahoo! User Interface Library Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Help getting tree working!   Message List  
Reply | Forward Message #5184 of 52113 |
Re: Help getting tree working!

Thank you Eric, much appreciated. I have things up and running now.

A couple additional things I don't understand how to do with my example:

How do I capture the node that the user clicks? I will need to grab
that information to make my database call.

Also, for each item in the tree, I want to build a hyperlink with
parameters. What is the best way to go about this?

I have looked everywhere for examples of a tree like this. Since I'm
not used to javascript (out of my J2EE comfort zone), I rely on a good
example, but havent' had any luck finding one)

Thanks again!








--- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:
>
> jmpow99,
>
> I've taken your code below and reworked it a bit to make it
> functional; take a look here:
>
> http://yuiblog.com/sandbox/yui/v0113/examples/treeview/dyn_ld.php
>
> There were a few issues in the code you pasted in here. Your
> singleton was not formed correctly and it wasn't clear that all of
> the functions were well-formed. However, without too many changes
> your code appears to work as desired, so you were definitely on the
> right track.
>
> Take a look at the functional example and let us know how things go
> from there.
>
> Regards,
> Eric
>
>
>
> Eric Miraglia
> Yahoo! Presentation Platform Engineering
>
>
>
> On Sep 25, 2006, at 2:13 PM, jmpow99 wrote:
>
> > I took Yahoo's dynamic tree example and started making changes to
> > statically simulate what calling the database. All data is in Arrays.
> > The buildTree method gets the first Array loaded up as the root. All
> > good.
> >
> > Now, I want to take the node the user clicks (call db with that id)
> > then load up that parent node with an array of it's children.
> >
> > I can't seem to figure out the next steps:
> >
> > 1.) How do I get a handle on the node the user clicked?
> > 2.)When I have the array of children, I'm looping through, how do I
> > assign them to their parent? This loop will only be for one parent at
> > a time.
> >
> > Thanks everyone, couldn't do it without these groups sharing
> > knowledge!
> >
> > Here is my current code:
> >
> > /*create namespace for examples:*/
> > YAHOO.namespace("example");
> >
> > /* Using Crockford's "Module Pattern": */
> > YAHOO.example.treeExample = function() {
> >
> > function buildTree() {
> >
> >
> > //create a new tree:
> > tree = new YAHOO.widget.TreeView("treeContainer");
> >
> > //turn dynamic loading on for entire tree:
> > tree.setDynamicLoad(loadNodeData, currentIconMode);
> >
> > //get root node for tree:
> > var root = tree.getRoot();
> >
> > //create dummy data for root
> > var mycars = new Array()
> > mycars[0] = "Saab"
> > mycars[1] = "Volvo"
> > mycars[2] = "BMW"
> > mycars[3] = "Ferrari"
> > mycars[4] = "Yugo"
> > mycars[5] = "Bentley"
> >
> > for (i=0;i<mycars.length;i++)
> > {
> >
> > new YAHOO.widget.TextNode(mycars[i], root, false);
> >
> > }
> >
> > tree.draw();
> > }
> >
> >
> >
> > function loadNodeData(node, fnLoadComplete) {
> >
> >
> >
> > //dummy data for bmw parent
> > var bmws = ["3 series","m series","5 series","7 series","6 series"];
> >
> > var children = bmws;
> >
> >
> > //loop through children array and need to load up the bmw parent.
> > How to do this???
> > for (var i=0; i<children.length; i++) {
> > thisModel = children[i];
> > var newNode = new YAHOO.widget.TextNode(thisModel, node, false);
> > }
> >
> > fnLoadComplete();
> > }
> >
> >
> > YAHOO.util.Event.addListener(window, "load",
> > YAHOO.example.treeExample.init, YAHOO.example.treeExample,true)
> >
> >
> >
>







Tue Sep 26, 2006 1:56 pm

jmpow99
Offline Offline
Send Email Send Email

Forward
Message #5184 of 52113 |
Expand Messages Author Sort by Date

I took Yahoo's dynamic tree example and started making changes to statically simulate what calling the database. All data is in Arrays. The buildTree method...
jmpow99
Offline Send Email
Sep 25, 2006
9:14 pm

jmpow99, I've taken your code below and reworked it a bit to make it functional; take a look here: ...
Eric Miraglia
ericmiraglia
Online Now Send Email
Sep 25, 2006
10:56 pm

Thank you Eric, much appreciated. I have things up and running now. A couple additional things I don't understand how to do with my example: How do I capture...
jmpow99
Offline Send Email
Sep 26, 2006
2:01 pm

jmpow99, I've revised the posted example to address the issue of capturing the node the user has clicked. Note that in the custom data object passed into the...
Eric Miraglia
ericmiraglia
Online Now Send Email
Sep 27, 2006
1:54 am

jmpow99, I have created dynamic tree view contol. But one problem i am getting. If I use [alert (" any thing")] in my loadNodeData function then correct tree...
anjumrizwi
Offline Send Email
Dec 21, 2006
1:41 pm

I've been grokking this example and have come to a somewhat philosophical dilemma (or, rather, trilemma :) As Eric's article correctly notes, the number of...
Felix Rabinovich
felikl
Offline Send Email
Jan 1, 2007
9:26 pm

I went with Option 3 for two reasons. First, it took the least amount of processing time overall (users can be so impatient!). Second, in the app that I...
smeep2k4
Offline Send Email
Jan 2, 2007
2:22 pm

I can second that! It seems to me that creating TextNode in handleSuccess() doesn't do anything on the screen. I haven't done a stand-alone snippet (my code is...
Felix Rabinovich
felikl
Offline Send Email
Jan 3, 2007
5:56 am

... Felix, Your dissertation makes good sense, yes. And I think the paragraph above highlights the key factors you need to account for in making your...
Eric Miraglia
ericmiraglia
Online Now Send Email
Jan 2, 2007
4:09 pm

Thanks for this idea... I just figured out how to do this part in practice. I've posted a live example if others are interested: ...
Alan Pinstein
apinstein
Offline Send Email
Feb 10, 2007
12:01 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help