WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 webfxtree, Mehmet Ates, August 14, 2003
     Re:webfxtree, Guilherme Blanco, August 14, 2003
         Re:webfxtree, Mehmet Ates, August 15, 2003
             Re:webfxtree, Mehmet Ates, August 15, 2003

Subject: Re:webfxtree From: Mehmet Ates Date: August 15, 2003

sorry my fault all working ok with your script i guess..

From: Mehmet Ates
Sent: August 15, 2003
Subject: Re:webfxtree

yeah ,its nice and working ok,

but do you see that when i click to see a path and then selecet another path , old dir stays highligthed.. so we see like 2 selected dirs... its the another problem ,do you have a solution for that?

From: Guilherme Blanco
Sent: August 14, 2003
Subject: Re:webfxtree

Seems that you tryed to do it in the hard way, my friend!

Well, it's a little big explanation, but you can see that it'll become much more easier than you expect.
First of all, add my code (check the thread: "Select xTree item based on its text"). Then, save your tree JS file in UTF-16 format.
Now, all browser can see special chars (my doubt in that post).

All you have to do now is implement a simple function to get the treeItem text and grab all parents of it. We'll do this with this function:

      var path = new Array();
      var i = 0;
      function tree_getItemPath( sText ) {
        var oNode = webFXTreeHandler.text[sText];
        if( oNode.parentNode ) {
          path[i] = sText;
          i++;
          sParentText = oNode.parentNode.text;
          tree_getItemPath( sParentText );
        }
      }

The whole path of your treeItem is now in the path array. In path[0], you have the searched item, and others are the folders (removed root, because it returns undefined.
I build a simple function to build the path.

      function showPath() {
        document.getElementById("area").innerText = "";
        for( var j = i - 1; j >= 0; j-- ) {
          document.getElementById("area").innerText += "/"+path[j];
        }
      }

All you have to do now is get the path using the text you can see in the tree.... for example: I have "Comentários" in my tree, I'll user: tree_getItemPath("Comentários");

Now, I added a DIV to display my result. It's the "area". And also added a button, do display this result.

If you're interested to check this code up and running, take a look at this page:
http://www.pontukom.com/test/test.html

Best regards,
Guilherme Blanco
ICQ: 33288081
MSN: guilhermeblanco@hotmail.com
São Carlos - SP/Brazil






Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX