Package com.smartgwt.client.widgets.tree

# Class TreeNode

java.lang.Object
com.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.core.RefDataClass
com.smartgwt.client.data.Record
com.smartgwt.client.widgets.grid.ListGridRecord
com.smartgwt.client.widgets.tree.TreeNode

All Implemented Interfaces:
  `HasHandlers`

Direct Known Subclasses:
  `GroupNode`, `NavItem`, `PaletteNode`

public class TreeNode extends ListGridRecord
Every node in the tree is represented by a TreeNode object which is an object literal with a set of properties that configure the node.

When a Tree is supplied as `TreeGrid.data` to `TreeGrid`, you can also set properties from `ListGridRecord` on the TreeNode (e.g. setting `ListGridRecord.enabled`:`false` on the node).

- ## Field Summary

  ### Fields inherited from class com.smartgwt.client.core.RefDataClass

  `id`

  ### Fields inherited from class com.smartgwt.client.core.DataClass

  `factoryCreated, factoryProperties`

  ### Fields inherited from class com.smartgwt.client.core.JsObject

  `jsObj`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TreeNode()`
  `TreeNode(JavaScriptObject jsObj)`
  `TreeNode(String name)`
  Constructor
  `TreeNode(String name, TreeNode... children)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Boolean`
  `getCanAcceptDrop()`
  Governs whether dragged data (typically other `treeNode`s) may be dropped over this node.
  `Boolean`
  `getCanDrag()`
  Governs whether this node can be dragged.
  `Boolean`
  `getEnabled()`
  Default property name denoting whether this record is enabled.
  `String`
  `getIcon()`
  This Property allows the developer to customize the icon displayed next to a node.
  `Integer`
  `getIconPadding()`
  Developers may customize the padding between the folder or leaf node icon and the text content of the tree cell for individual nodes.
  `String`
  `getName()`
  Provides a name for the node that is unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file system.
  `static TreeNode`
  `getOrCreateRef(JavaScriptObject jsObj)`
  `Boolean`
  `getShowDropIcon()`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a drop state icon should be displayed when the user drop-hovers over this folder.
  Set `node.showDropIcon` to true to show the drop state icon, or false to suppress this.
  If not specified, this behavior is determined by `TreeGrid.showCustomIconDrop` for this node.
  `Boolean`
  `getShowOpenIcon()`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether an open state icon should be displayed when the folder is open.
  `Boolean`
  `getShowSelectedIcon()`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a selected state icon should be displayed when the folder is open.
  `String`
  `getTitle()`
  The title of the node as it should appear next to the node icon in the `Tree`.
  `TreeNode`
  `setCanAcceptDrop(Boolean canAcceptDrop)`
  Governs whether dragged data (typically other `treeNode`s) may be dropped over this node.
  `TreeNode`
  `setCanDrag(Boolean canDrag)`
  Governs whether this node can be dragged.
  `void`
  `setChildren(TreeNode[] children)`
  For trees with the modelType "children", this property specifies the children of this TreeNode.
  `TreeNode`
  `setEnabled(Boolean enabled)`
  Default property name denoting whether this record is enabled.
  `TreeNode`
  `setIcon(String icon)`
  This Property allows the developer to customize the icon displayed next to a node.
  `TreeNode`
  `setIconPadding(Integer iconPadding)`
  Developers may customize the padding between the folder or leaf node icon and the text content of the tree cell for individual nodes.
  `void`
  `setID(String id)`
  For trees with `modelType` "parent", this property specifies the unique ID of this node.
  `void`
  `setIsFolder(boolean isFolder)`
  Set to `true` to explicitly mark this node as a folder.
  `void`
  `setName(String name)`
  Provides a name for the node that is unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file system.
  `void`
  `setParentID(String parentID)`
  For trees with modelType "parent", this property specifies unique parent ID of this node.
  `TreeNode`
  `setShowDropIcon(Boolean showDropIcon)`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a drop state icon should be displayed when the user drop-hovers over this folder.
  Set `node.showDropIcon` to true to show the drop state icon, or false to suppress this.
  If not specified, this behavior is determined by `TreeGrid.showCustomIconDrop` for this node.
  `TreeNode`
  `setShowOpenIcon(Boolean showOpenIcon)`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether an open state icon should be displayed when the folder is open.
  `TreeNode`
  `setShowSelectedIcon(Boolean showSelectedIcon)`
  For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a selected state icon should be displayed when the folder is open.
  `TreeNode`
  `setTitle(String title)`
  The title of the node as it should appear next to the node icon in the `Tree`.

  ### Methods inherited from class com.smartgwt.client.widgets.grid.ListGridRecord

  `get_baseStyle, get_canEdit, get_canRemove, getBackgroundComponent, getCanExpand, getCanSelect, getCustomStyle, getDetailDS, getEmbeddedComponent, getEmbeddedComponentFields, getEmbeddedComponentPosition, getIncludeInSummary, getIsGridSummary, getIsGroupSummary, getIsSeparator, getLinkText, getShowRollOver, getSingleCellValue, set_baseStyle, set_canEdit, set_canRemove, setBackgroundComponent, setCanExpand, setCanSelect, setCustomStyle, setDetailDS, setEmbeddedComponent, setEmbeddedComponentFields, setEmbeddedComponentPosition, setIncludeInSummary, setIsGridSummary, setIsGroupSummary, setIsSeparator, setLinkText, setShowRollOver, setSingleCellValue`

  ### Methods inherited from class com.smartgwt.client.data.Record

  `convertToRecordArray, copyAttributes, copyAttributesInto, getAttributeAsRecordArray, getAttributeAsRecordList, getPaletteDefaults, isARecord, toMap`

  ### Methods inherited from class com.smartgwt.client.core.RefDataClass

  `getRef, getRef, internalSetID`

  ### Methods inherited from class com.smartgwt.client.core.DataClass

  `applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated`

  ### Methods inherited from class com.smartgwt.client.core.JsObject

  `equals, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObj`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TreeNode

    public TreeNode()

  - ### TreeNode

    public TreeNode(JavaScriptObject jsObj)

  - ### TreeNode

    public TreeNode(String name)
    Constructor
    Parameters:
      `name` - the name

  - ### TreeNode

    public TreeNode(String name, TreeNode... children)
    Constructor
    Parameters:
      `name` - the name
      `children` - the children nodes

- ## Method Details

  - ### getOrCreateRef

    public static TreeNode getOrCreateRef(JavaScriptObject jsObj)

  - ### setCanAcceptDrop

    public TreeNode setCanAcceptDrop(Boolean canAcceptDrop)
    Governs whether dragged data (typically other `treeNode`s) may be dropped over this node. Only has an effect if this node is displayed in a `TreeGrid` where `TreeGrid.canAcceptDroppedRecords`, `TreeGrid.canReorderRecords` or `TreeGrid.canReparentNodes` is true.

    Note : This is an advanced setting

    Overrides:
      `setCanAcceptDrop` in class `ListGridRecord`
    Parameters:
      `canAcceptDrop` - New canAcceptDrop value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls

  - ### getCanAcceptDrop

    public Boolean getCanAcceptDrop()
    Governs whether dragged data (typically other `treeNode`s) may be dropped over this node. Only has an effect if this node is displayed in a `TreeGrid` where `TreeGrid.canAcceptDroppedRecords`, `TreeGrid.canReorderRecords` or `TreeGrid.canReparentNodes` is true.
    Overrides:
      `getCanAcceptDrop` in class `ListGridRecord`
    Returns:
      Current canAcceptDrop value. Default value is null

  - ### setCanDrag

    public TreeNode setCanDrag(Boolean canDrag)
    Governs whether this node can be dragged. Only has an effect if this node is displayed in a `TreeGrid` where `TreeGrid.canDragRecordsOut`, `TreeGrid.canReorderRecords` or `TreeGrid.canReparentNodes` is `true`.

    Note : This is an advanced setting

    Overrides:
      `setCanDrag` in class `ListGridRecord`
    Parameters:
      `canDrag` - New canDrag value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls

  - ### getCanDrag

    public Boolean getCanDrag()
    Governs whether this node can be dragged. Only has an effect if this node is displayed in a `TreeGrid` where `TreeGrid.canDragRecordsOut`, `TreeGrid.canReorderRecords` or `TreeGrid.canReparentNodes` is `true`.
    Overrides:
      `getCanDrag` in class `ListGridRecord`
    Returns:
      Current canDrag value. Default value is null

  - ### setEnabled

    public TreeNode setEnabled(Boolean enabled)
    Default property name denoting whether this record is enabled. Property name may be modified for some grid via `ListGrid.recordEnabledProperty`.
    Overrides:
      `setEnabled` in class `ListGridRecord`
    Parameters:
      `enabled` - New enabled value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - Disabled rows Example

  - ### getEnabled

    public Boolean getEnabled()
    Default property name denoting whether this record is enabled. Property name may be modified for some grid via `ListGrid.recordEnabledProperty`.
    Overrides:
      `getEnabled` in class `ListGridRecord`
    Returns:
      Current enabled value. Default value is null
    See Also:
      - Disabled rows Example

  - ### setIcon

    public TreeNode setIcon(String icon)
    This Property allows the developer to customize the icon displayed next to a node. Set `node.icon` to the URL of the desired icon to display and it will be shown instead of the standard `TreeGrid.nodeIcon` for this node.
    Note that if `showOpenIcon` and/or `showDropIcon` is true for this node, customized icons for folder nodes will be appended with the `TreeGrid.openIconSuffix` or `TreeGrid.dropIconSuffix` suffixes on state change as with the standard `TreeGrid.folderIcon` for this treeGrid. Also note that for custom folder icons, the `TreeGrid.closedIconSuffix` will never be appended.

    You can change the name of this property by setting `TreeGrid.customIconProperty`.

    Parameters:
      `icon` - New icon value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - `SCImgURL`

  - ### getIcon

    public String getIcon()
    This Property allows the developer to customize the icon displayed next to a node. Set `node.icon` to the URL of the desired icon to display and it will be shown instead of the standard `TreeGrid.nodeIcon` for this node.
    Note that if `showOpenIcon` and/or `showDropIcon` is true for this node, customized icons for folder nodes will be appended with the `TreeGrid.openIconSuffix` or `TreeGrid.dropIconSuffix` suffixes on state change as with the standard `TreeGrid.folderIcon` for this treeGrid. Also note that for custom folder icons, the `TreeGrid.closedIconSuffix` will never be appended.

    You can change the name of this property by setting `TreeGrid.customIconProperty`.

    Returns:
      Current icon value. Default value is null
    See Also:
      - `SCImgURL`

  - ### setIconPadding

    public TreeNode setIconPadding(Integer iconPadding)
    Developers may customize the padding between the folder or leaf node icon and the text content of the tree cell for individual nodes.

    You can change the name of this property by setting `TreeGrid.iconPaddingProperty`

    Note : This is an advanced setting

    Parameters:
      `iconPadding` - New iconPadding value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls

  - ### getIconPadding

    public Integer getIconPadding()
    Developers may customize the padding between the folder or leaf node icon and the text content of the tree cell for individual nodes.

    You can change the name of this property by setting `TreeGrid.iconPaddingProperty`

    Returns:
      Current iconPadding value. Default value is null

  - ### setName

    public void setName(String name)
    Provides a name for the node that is unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file system. See `Tree.getPath()`.

    If the nameProperty is not set on a given node, the `id` will be used instead. If this is also missing, `Tree.getName()` and `Tree.getPath()` will auto-generate a unique name for you. Thus names are not required, but if the dataset you are using already has usable names for each node, using them can make APIs such as `Tree.find()` more useful. Alternatively, if your dataset has unique ids consider providing those as `id`.

    If a value provided for the nameProperty of a node (e.g. node.name) is not a string, it will be converted to a string by the Tree via ""+value.

    This property is also used as the default title for the node (see `Tree.getTitle()`) if `title` is not specified.

    Note: the name of this property can be changed by setting `Tree.nameProperty`.

    Parameters:
      `name` - New name value. Default value is null, but see below
    See Also:
      - `Tree.setNameProperty(java.lang.String)`
      - `Tree.setPathDelim(java.lang.String)`
      - `Tree.getPath(com.smartgwt.client.widgets.tree.TreeNode)`
      - `Tree.getTitle(com.smartgwt.client.widgets.tree.TreeNode)`

  - ### getName

    public String getName()
    Provides a name for the node that is unique among its immediate siblings, thus allowing a unique path to be used to identify the node, similar to a file system. See `Tree.getPath()`.

    If the nameProperty is not set on a given node, the `id` will be used instead. If this is also missing, `Tree.getName()` and `Tree.getPath()` will auto-generate a unique name for you. Thus names are not required, but if the dataset you are using already has usable names for each node, using them can make APIs such as `Tree.find()` more useful. Alternatively, if your dataset has unique ids consider providing those as `id`.

    If a value provided for the nameProperty of a node (e.g. node.name) is not a string, it will be converted to a string by the Tree via ""+value.

    This property is also used as the default title for the node (see `Tree.getTitle()`) if `title` is not specified.

    Note: the name of this property can be changed by setting `Tree.nameProperty`.

    Returns:
      Current name value. Default value is null, but see below
    See Also:
      - `Tree.getNameProperty()`
      - `Tree.getPathDelim()`
      - `Tree.getPath(com.smartgwt.client.widgets.tree.TreeNode)`
      - `Tree.getTitle(com.smartgwt.client.widgets.tree.TreeNode)`

  - ### setShowDropIcon

    public TreeNode setShowDropIcon(Boolean showDropIcon)
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a drop state icon should be displayed when the user drop-hovers over this folder.
    Set `node.showDropIcon` to true to show the drop state icon, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconDrop` for this node.

    You can change the name of this property by setting `TreeGrid.customIconDropProperty`.

    Note : This is an advanced setting

    Parameters:
      `showDropIcon` - New showDropIcon value. Default value is false
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - `TreeGrid.setCustomIconProperty(java.lang.String)`
      - `TreeGrid.setShowCustomIconDrop(java.lang.Boolean)`

  - ### getShowDropIcon

    public Boolean getShowDropIcon()
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a drop state icon should be displayed when the user drop-hovers over this folder.
    Set `node.showDropIcon` to true to show the drop state icon, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconDrop` for this node.

    You can change the name of this property by setting `TreeGrid.customIconDropProperty`.

    Returns:
      Current showDropIcon value. Default value is false
    See Also:
      - `TreeGrid.getCustomIconProperty()`
      - `TreeGrid.getShowCustomIconDrop()`

  - ### setShowOpenIcon

    public TreeNode setShowOpenIcon(Boolean showOpenIcon)
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether an open state icon should be displayed when the folder is open. Set `node.showOpenIcon` to true to show the open state icons, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconOpen` for this node.

    You can change the name of this property by setting `TreeGrid.customIconOpenProperty`.

    Note : This is an advanced setting

    Parameters:
      `showOpenIcon` - New showOpenIcon value. Default value is false
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - `TreeGrid.setCustomIconProperty(java.lang.String)`
      - `TreeGrid.setShowCustomIconOpen(java.lang.Boolean)`

  - ### getShowOpenIcon

    public Boolean getShowOpenIcon()
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether an open state icon should be displayed when the folder is open. Set `node.showOpenIcon` to true to show the open state icons, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconOpen` for this node.

    You can change the name of this property by setting `TreeGrid.customIconOpenProperty`.

    Returns:
      Current showOpenIcon value. Default value is false
    See Also:
      - `TreeGrid.getCustomIconProperty()`
      - `TreeGrid.getShowCustomIconOpen()`

  - ### setShowSelectedIcon

    public TreeNode setShowSelectedIcon(Boolean showSelectedIcon)
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a selected state icon should be displayed when the folder is open. Set `node.showSelectedIcon` to true to show the selected state icons, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconSelected` for this node.

    You can change the name of this property by setting `TreeGrid.customIconSelectedProperty`.

    Note : This is an advanced setting

    Parameters:
      `showSelectedIcon` - New showSelectedIcon value. Default value is false
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - `TreeGrid.setCustomIconProperty(java.lang.String)`
      - `TreeGrid.setShowCustomIconSelected(java.lang.Boolean)`

  - ### getShowSelectedIcon

    public Boolean getShowSelectedIcon()
    For folder nodes showing custom icons (set via `icon`), this property allows the developer to specify on a per-node basis whether a selected state icon should be displayed when the folder is open. Set `node.showSelectedIcon` to true to show the selected state icons, or false to suppress this.
    If not specified, this behavior is determined by `TreeGrid.showCustomIconSelected` for this node.

    You can change the name of this property by setting `TreeGrid.customIconSelectedProperty`.

    Returns:
      Current showSelectedIcon value. Default value is false
    See Also:
      - `TreeGrid.getCustomIconProperty()`
      - `TreeGrid.getShowCustomIconSelected()`

  - ### setTitle

    public TreeNode setTitle(String title)
    The title of the node as it should appear next to the node icon in the `Tree`. If left unset, the value of `name` is used by default. See the description in `Tree.getTitle()` for full details.

    Note: the name of this property can be changed by setting `Tree.titleProperty`.

    Parameters:
      `title` - New title value. Default value is null
    Returns:
      `TreeNode` instance, for chaining setter calls
    See Also:
      - `Tree.setTitleProperty(java.lang.String)`
      - `Tree.getTitle(com.smartgwt.client.widgets.tree.TreeNode)`
      - `HTMLString`

  - ### getTitle

    public String getTitle()
    The title of the node as it should appear next to the node icon in the `Tree`. If left unset, the value of `name` is used by default. See the description in `Tree.getTitle()` for full details.

    Note: the name of this property can be changed by setting `Tree.titleProperty`.

    Returns:
      Current title value. Default value is null
    See Also:
      - `Tree.getTitleProperty()`
      - `Tree.getTitle(com.smartgwt.client.widgets.tree.TreeNode)`
      - `HTMLString`

  - ### setID

    public void setID(String id)
    For trees with `modelType` "parent", this property specifies the unique ID of this node. The unique ID of a node, together with the unique ID of its parent (see `parentId`) is used by `Tree.linkNodes(com.smartgwt.client.widgets.tree.TreeNode[])` to link a list of nodes into a tree.

    Note: the name of this property can be changed by setting `idField`.

    Parameters:
      `id` - id Default value is null

  - ### setParentID

    public void setParentID(String parentID)
    For trees with modelType "parent", this property specifies unique parent ID of this node. The unique ID of a node, together with the unique ID of its parent is used by `Tree.linkNodes(com.smartgwt.client.widgets.tree.TreeNode[])` to link a list of nodes into a tree.

    Note: the name of this property can be changed by setting `parentIdField`.

    Parameters:
      `parentId` - parentId Default value is null

  - ### setIsFolder

    public void setIsFolder(boolean isFolder)
    Set to `true` to explicitly mark this node as a folder. See `Tree.isFolder(com.smartgwt.client.widgets.tree.TreeNode)` for a full description of how the `Tree` determines whether a node is a folder or not.

    Note: the name of this property can be changed by setting `isFolderProperty`.

    Parameters:
      `isFolder` - isFolder Default value is null

  - ### setChildren

    public void setChildren(TreeNode[] children)
    For trees with the modelType "children", this property specifies the children of this TreeNode.

    Note: the name of this property can be changed by setting `childrenProperty`

    Parameters:
      `children` - children Default value is null