Databound Tree Tutorial

With the Nitobi Tree component you can choose to bind to a dataset on the server side, similar to how Grid and ComboBox can bind to server-side data.

From The Declaration

On the client side, all you need to do to enable databound mode for the Tree is to specify a URL for the gethandler attribute. For example, if you had a gethandler called simplegethandler.php, your Tree declaration would be as follows:

<ntb:tree id="tree1" cssclass="folder" gethandler="simplegethandler.php"></ntb:tree>

When the Tree first loads and when you expand a node, it will make a request to the gethandler which will return the appropriate data.

The Request Parameters

On the server-side, we need to define a script to get records from the database, construct an XML document from those records, and return the result back to the client.

When the Tree makes a request to the server, it makes a request like the following:

simplegethandler.php?id=13&label=Australia&nodetype=node&haschildren="true"&treeId="tree1"

The parameters that are passed are:

  • id - Tells us the id of the node requesting its children (this will be blank if the tree is requesting its children)
  • label - The label on the node making the request
  • nodetype - Will either be node or leaf
  • haschildren - true if the node has children, false otherwise
  • treeId - The id attribute of the Tree declaration

Writing the GetHandler

We have separate tutorials available for each platform you can use:

page_revision: 1, last_edited: 1224792021|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License