Treegrid supports both the Nested Set model and the Adjacency model. Good articles describing the Nested Set model can be found here:
This feature uses the following properties and methods of the basic grid.
| Property | Type | Description | Default |
|---|---|---|---|
| ExpandColClick | boolean | when true, the tree is expanded and/or collapsed when we click on the text of the expanded column, not only on the image | true' |
| treeGrid | boolean | Enables (disables) tree grid. When this option is set to true, the following features are disabled:
|
true |
| treeModel | string | 'nested' or 'adjacency' | 'nested' |
| treeReader | array | 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 |
| Method | Parameters | Description |
|---|---|---|
| collapseNode | record | Collapse the node at specified record |
| collapseRow | record | Collapse 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 | Expand 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 | none | 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) |
In the methods above, record means the current record, which can be obtained via the getInd method
postData:{nodeid:rc.id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}
SELECT category_name, level, lft, rgt FROM categories WHERE lft > n_left AND rgt < n_right AND level = n_level +1 ORDER BY lft;