TreeView 2.0 Released

TreeViewClick here for the demo.

About a week ago I released version 2.0 of TreeView, a PHP class for adding expandable tree controls to web applications. This is actually a big milestone toward my goal of building Ajax support. The major new features in TreeView 2.0 are:

Client-side mode
I coded the Javascript to animate the expanding and collapsing of nodes from the ground-up. The result is a highly responsive and smooth expanding tree without any page reloading. The code is very clean and works in both IE and Firefox on Windows.

PHP Session Support
It used to be that the more nodes you open, the longer query string became. Now you can enable session support to keep track of the open nodes and keep the query string very short.

Why Ajax?
Although client-side trees are great, it isn’t very practical for large trees because all of the nodes must be printed when the page first loads. If you have ten thousand nodes, you could end up with a long download and may even overwhelm the web browser. Usually people that have large trees give up on a client-side tree and go with page reloading instead.

With Ajax it is possible to eliminate the need to print all the nodes to the page at once and also eliminate page reloading. Ajax can retrieve the child nodes exactly when the user expands a node and then display them. It’s the ultimately efficient tree!

Update (2005/11/25): If you’re a Mac user, let me know if it works in IE for Mac, Safari, and/or Camino.

  • Hey, works perfectly on my Linux in Firefox and Konqueror as well.


  • BT

    Sweet! Thanks Bojan.

    And thanks for reporting that bug in IE under Windows on the UNB computers where the images won’t display. I still have to try recreate that bug, hopefully by boosting the security policies in IE or Windows.

  • It’s weird becuase it’s just the UNB school computers. It works on my IE at home, althought I only have SP1 and an older IE. I’ve tried resetting IE settings to default on the school computer, and it still wouldn’t work correctly. It’s really strange.

  • I created an ajax js/php tree at my previous company as well. I had to display 50,000 items in an expandable tree. Obviously that’s too much data to display at once so each expansion of the tree called back to the server to get the current list, then cached that on the client side. Its one of the great uses for ajax. keep up the good work