This topic discusses some common ways to configure selections in the igTree
™ control.
This topic contains the following sections:
The table below lists the required background you need for fully understanding the information in this topic.
Background type | Content |
---|---|
Topics | You need to first read the Getting Started with igTree topic. |
External Resources | You need to first read the following articles: jQuery bind() API jQuery live() API |
The table below lists the configurable behaviors of the igTree
control.
Configurable behavior | Configuration details | Configuration properties |
---|---|---|
Configure checkboxes |
The igTree control supports bi-state and tri-state checkboxes. When tri-state checkboxes are enabled, the parent nodes update dynamically to reflect whether their children are all selected, all unselected, or partially selected.
|
|
Get checked nodes |
The igTree control has an API to get all checked nodes, all unchecked nodes, and all partially selected nodes.
|
|
Handle selection and checkbox events | Capture selection events to perform logic in response to a selection operation occurring. |
|
Select/Deselect Nodes | Use these methods to select and deselect modes through code. |
|
The igTree
control supports bi-state and tri-state checkboxes. When tri-state checkboxes are enabled, the parent nodes reflect whether their children are all selected, all unselected, or partially selected.
The table below maps the desired behaviors to property settings. The properties are accessed through the igTree
’s options.
In order to… | Use this property: | And set it to… |
---|---|---|
Enable bi-state checkboxes | checkboxMode | biState |
Enable tri-state checkboxes | checkboxMode | triState |
The image below demonstrates tri-state checkboxes as a result of the following settings:
Property | Setting | Preview |
---|---|---|
checkboxMode | triState |
The image below demonstrates tri-state checkboxes as a result of the following settings:
Property | Setting | Preview |
---|---|---|
checkboxMode | biState |
For detailed information about these properties, refer to their listing in the property reference section:
The igTree
has an API to get all checked nodes, all unchecked nodes, and all partially selected nodes.
The table below maps the desired behaviors to property settings. The properties are accessed through the igTree
methods.
In order to… | Use this method: | Returns… |
---|---|---|
Get all checked nodes | checkedNodes | array of Nodes |
Get all unchecked nodes | uncheckedNodes | array of Nodes |
Get all partially checked nodes | partiallyCheckedNodes | array of Nodes |
The code below demonstrates how to get all checked nodes as a result of the following:
Method | Returns… |
---|---|
checkedNodes | array of Nodes |
In JavaScript:
var nodes = $("#tree").igTree("checkedNodes");
By handling the selection and checkbox events, you can perform custom logic in response to these operations. These events can be configured when a widget is initialized in jQuery or on the client using the bind or live jQuery functions.
The table below maps the desired behaviors to property settings. The properties are accessed through the igTree
events.
In order to… | Use this property: | And set it to… |
---|---|---|
Handle an event before a selection operation | selectionChanging | function() |
Handle an event after a selection operation | selectionChanged | function() |
Handle an event before a checkbox operation | nodeCheckstateChanging | function() |
Handle an event before a checkbox operation | nodeCheckstateChanged | function() |
The code below demonstrates configuring a selection during instantiation of the igTree
using the following:
Property | Setting |
---|---|
selectionChanged | function(evt, ui){ } |
nodeCheckstateChanged | function(evt, ui){ } |
In HTML:
$("#tree").igTree({
dataSource: data,
checkboxMode: "triState",
bindings: {
textKey: 'Text',
childDataProperty: 'Nodes'
},
selectionChanged: function (evt, ui) {
},
nodeCheckstateChanged: function (evt, ui) {
}
});
The code below demonstrates handling selection and checkbox events using jQuery bind and live functions. The type of the events are lower case strings constructed by appending igTree
to the beginning of the event name.
In HTML:
$("#tree").bind("igtreeselectionchanging", function (evt, ui) {
});
$("#tree").live("igtreenodecheckstatechanged", function (evt, ui) {
});
The code below demonstrates how to cancel the selection operation by returning false from the event handler function. The same approach can be used for an –ing function for the igTree
. In this code example, cancel represents the Boolean result of application logic that determines whether selection should occur or not.
In HTML:
$("#tree").live("igtreenodecheckstatechanging", function (evt, ui) {
if (cancel == true)
return false;
});
Following are some other topics you may find useful.
View on GitHub