gridx.modules.Tree
Object » _Module » gridx.modules.Tree
dojo.require("gridx.modules.Tree");
Defined in gridx/modules/Tree.js
This module is used for creation, destruction and management of the Tree Grid.
There are two kind of Tree Grid: columnar or nested, it will be indicated by
the argument type
, and the layout of the TreeGrid will be defined by extended
structure
argument.
Examples:
Example 1
For the columnar Tree Grid, the column which is expandable is indicated by the new added attribute `expandField`, and the value of the `expandField` is one or more attribute names (attributes in the meta data) that specify that item's children. See the quick sample below: sample of data source
{ identifier: 'name',
label: 'name',
items: [
{ name:'Africa', type:'continent', children: [
{ name:'Egypt', type:'country' },
{ name:'Kenya', type:'country', children:[
{ name:'Nairobi', type:'city', adults: 70400, popnum: 2940911 },
{ name:'Mombasa', type:'city', adults: 294091, popnum: 707400 } ]
},
{ name:'Sudan', type:'country', children:
{ name:'Khartoum', type:'city', adults: 480293, popnum: 1200394 }
} ]
},
{ name:'Asia', type:'continent', children:[
{ name:'China', type:'country' },
{ name:'India', type:'country' },
{ name:'Russia', type:'country' },
{ name:'Mongolia', type:'country' } ]
},
{ name:'Australia', type:'continent', population:'21 million', children:
{ name:'Commonwealth of Australia', type:'country', population:'21 million'}
} ]
}
define the grid structure
var structure = [
{name: "Name", field: "name", expandLevel: 'all'},
{name: "Type", field: "type"},
{name: "Population", field: "population"}
];
For the nested TreeGrid, there could be more than one column can be expanded,
so the structure might be a little more complicated. There is ONLY one attribute
name can be assigned to the `expandField` as children, and there would be a
attribute called `nestedLevel` to specify the hierarchy of the column.
A quick sample:
sample of data source
{ identifier: 'id',
items: [
{ id: "1", playername: "Player 1", seasons: [
{ id: "2", seasonindex: "Season 1", games: [
{ id: "3", gameindex: "Game 1", quarters: [
{id: "4", point: "3", rebound: "3", assistant: "1"},
{id: "5", point: "5", rebound: "0", assistant: "0"},
{id: "6", point: "0", rebound: "1", assistant: "3"},
{id: "7", point: "2", rebound: "2", assistant: "0"} ]
},
{ id: "8", gameindex: "Game 2", quarters: [
{id: "9", point: "3", rebound: "0", assistant: "2"},
{id: "10", point: "0", rebound: "4", assistant: "1"},
{id: "11", point: "5", rebound: "0", assistant: "1"},
{id: "12", point: "10", rebound: "2", assistant: "0"} ]
} ]
},
{ id: "13", seasonindex: "Season 2" } ]
} ]
}
define the tree grid type
treeNested: true;
define the grid structure
var structure = [
{name: "Player", field: "playername", expandLevel: 1},
{name: "Season", field: "seasonindex", expandLevel: 2},
{name: "Game", field: "gameindex", expandLevel: 3},
{name: "Point", field: "point"},
{name: "Rebound", field: "rebound"},
{name: "Assistant", field: "assistant"}
];
Property Summary
Method Summary
- _clear()
- _createCellWrapper(wrappers, rowId, colId)
- _getAbsoluteVisualIndex(parentId, rowIndex)
- _getChild(visualIndex, info)
- _initExpandLevel()
- _initFocus()
- _logicCollapse(id)
- _logicExpand(id)
- _onAfterRow(row)
- _onCellClick(e)
- _onKey(e)
- _updateBody(id)
- canExpand(id) Check whether a row can be expanded.
- collapse(id, skipUpdateBody) returns dojo.Deferred Collapse a row.
- collapseRecursive(id, skipUpdateBody) Recursively collapse a row recursively and all its descendants.
- constructor()
- expand(id, skipUpdateBody) returns dojo.Deferred Expand the row.
- expandRecursive(id, skipUpdateBody) Recursively expand a row and all its descendants.
- getAPIPath()
- getRowInfoByVisualIndex(visualIndex, rootStart) returns Object Get row info (including row index, row id, parent id, etc) by row visual index.
- getVisualIndexByRowInfo(parentId, rowIndex, rootStart)
- getVisualSize(start, count, parentId)
- isExpanded(id) returns Boolean Check whether a row is already expanded.
- load(args)
- preload()
Event Summary
- onCollapse(id) Fired when a row is collapsed.
- onExpand(id) Fired when a row is expanded.
Attached Objects
Properties
Methods
Overrides _Module
Whether the row can be expanded.
Check whether a row can be expanded.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
Overrides _Module
Returns dojo.Deferred: A deferred object indicating whether this collapsing process has completed.
Collapse a row.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
skipUpdateBody | Boolean | If set to true the grid will not automatically refresh itself after this method, so that several grid operations can be executed altogether. |
Overrides _Module
A deferred object indicating whether this collapsing process has completed.
Recursively collapse a row recursively and all its descendants.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
skipUpdateBody | Boolean | If set to true the grid will not automatically refresh itself after this method, so that several grid operations can be executed altogether. |
Overrides _Module
Returns dojo.Deferred: A deferred object indicating whether this expanding process has completed.
Expand the row.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
skipUpdateBody | Boolean | If set to true the grid will not automatically refresh itself after this method, so that several grid operations can be executed altogether. |
Overrides _Module
A deferred object indicating whether this expanding process has completed.
Recursively expand a row and all its descendants.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
skipUpdateBody | Boolean | If set to true the grid will not automatically refresh itself after this method, so that several grid operations can be executed altogether. |
Overrides _Module
Returns Object: A row info object
Get row info (including row index, row id, parent id, etc) by row visual index.
Parameter | Type | Description |
---|---|---|
visualIndex | Integer | |
rootStart | Integer |
Overrides _Module
Returns Boolean: Whether the row is expanded.
Check whether a row is already expanded.
Parameter | Type | Description |
---|---|---|
id | String | The row ID |
Events
Overrides _Module
Fired when a row is collapsed.
Parameter | Type | Description |
---|---|---|
id | String | The ID of the collapsed row. |