concept node in category ext js

This is an excerpt from Manning's book Ext JS in Action, Second Edition.
This manifests as a whole tree being represented by a table, with each node belonging to a column in a respective row. A node is, by default, a representation of a text and an icon, but it can be extended for a more advanced usage. Nodes that belong to a Model instance can be assigned any additional data. This extra information can be used to add new columns to the left or right of the core tree, implementing an often-needed TreeGrid functionality. The whole process is laid out in figure 9.1.
To analyze the client/server interaction model with the tree panel, let’s start with the load request fired off by the automatic expansion of the root node, as shown in figure 9.4. Remember that you set the root’s expanded property to true and that this expands a node when it’s rendered, thus either rendering the children if they’re in memory or firing a load request.
As you can see, the first request to the getCompany.php controller was made with a single parameter, node, which has a value of myCompany. Can you remember where you set that value and which property you set it to? If you said “the id property of the root node,” you’re correct! When an asynchronously loading node is being expanded for the first time, the store will use its id property to pass the child data to the controller.
The controller will accept this parameter and query the database for all nodes associated with that id and return a list of objects, as illustrated in figure 9.5. In this figure you see an array of objects that defines a list of departments. Each object has both text and id properties. The text applies to the label of the node. Notice that the departments lack the leaf and children properties. Are these leaf or branch nodes? They’re branch nodes. Because neither property is defined, they’re treated as branch nodes. This means that when they’re initially expanded, TreeStore will invoke an Ajax.request, passing the department’s ID as the node parameter. The controller will accept the node parameter and return a list of employees for that department.
Using what you just learned, you can safely predict that when you expand the Accounting department node a request to the getCompany.php controller will be made with a single parameter, node, passed with a value of 'Accounting'. Let’s take a quick look at the results from the controller request, shown in figure 9.6.
As you look at the JSON results, you see that a list of objects is returned, each with id, text, and leaf properties. Remember, because the leaf property is set, the nodes appear as nonexpanding leaf nodes.
To create a node interface, you’re going to have to recycle some of the work already done, while still using some of the cool JavaScript features, like closures. Because the tree editor needs to bind and display on top of a node, you’ll need to inject a node interface into the tree panel and trigger an edit operation on the new node. As soon as you create the node, the store will sync the new data to the server. Because you’ll get a chance to edit the name of the node immediately on creation, the store will once again sync the data once you update the text. This works similarly to the way rows are added to the editor grid you created in the previous chapter. The next listing contains the code for the create-node functionality.