Currently tree grid supports only the Nested Set model. Good articles describing this can be found here:
This feature uses the following properties, events and methods of the parent grid.
| Property | Type | Description | Default |
|---|---|---|---|
| treeGrid | boolean | Enables (disables) tree grid. When this option is set to true, the following features are disabled:
|
true |
| treeReader | array | Array which extends the colModel defined in the basic grid. The fields described here are added to end of the colModel array and are hidden. This means that the data returned from the server should have values for these fields. For a full description of all valid values see treeReader properties. | empty array |
All methods are public and can be used
In the methods below, record means the current record, which can be obtained via the getInd method
| Method | Parameters | Description |
|---|---|---|
| collapseNode | record | collapse the node at specified record |
| collapseRow | record | collapses the current row |
| delTreeNode | rowid | Where rowid is the id of the row. Deletes the specified node and all child nodes of that node |
| expandNode | record | expand the node at the specified record |
| expandRow | record | expands the current row |
| getInd | object, rowid, rc | where object is the current set of grid rows (returned from jQuery("grid_id).rows); rowid is the id of the row; and rc should be set to true |
| getNodeAncestors | record | returns the ancestors of the specified record |
| getNodeDepth | record | returns the depth of the specified record |
| getNodeParent | record | returns the parent node of the specified record |
| getNodeChildren | record | returns the child nodes of the specified record; returns empty array if none |
| getRootNodes | returns an array of the current root nodes | |
| isNodeLoaded | record | returns true if the node is already loaded |
| isVisibleNode | record | returns true or false if the node is visible or not |
| setTreeRow | rowid, data | this method is just like setRowData, but can be used when treeGrid is enabled. When we use tree grid we should use setTreeRow instead of setRowData (this will be improved in the future releases - autodetecting the mode and use only one method - setRowData) |
| SortTree | direction | direction is 'asc' or 'desc'; sorts the tree with the currently set sortname (sortname is from grid option) |
Treegrid requires some additions to the css. The current release of jqGrid includes these in the accompanying css files. If you are using custom css files, you will need to add these:
In this case, postData array would like this:
Once all the nodes are loaded we do not make any other request to the server