[]
        
(Showing Draft Content)

TreeNode Class

TreeNode Class

Class that represents a node in a TreeView.

Heirarchy

  • TreeNode

Constructors

constructor

  • Initializes a new instance of a TreeNode.

    Parameters

    • treeView: TreeView

      TreeView that contains the node.

    • nodeElement: HTMLElement

      HTML element that represents the node on the TreeView.

    Returns TreeNode

Properties

checkBox

checkBox: HTMLInputElement

Gets the HTMLInputElement that represents the checkbox associated with this node.

dataItem

dataItem: any

Gets the data item that this node represents.

element

element: HTMLElement

Gets the HTML element that represents this node on the TreeView.

hasChildren

hasChildren: boolean

Gets a value that indicates whether this node has child nodes.

hasPendingChildren

hasPendingChildren: boolean

Gets a value that indicates whether this node has pending child nodes that will be lazy-loaded when the node is expanded.

index

index: number

Gets this node's index within the parent's node collection.

isChecked

isChecked: boolean

Gets or sets a value that determines whether this node is checked.

When the value of this property changes, child and ancestor nodes are automatically updated, and the parent TreeView's TreeView.checkedItemsChanged event is raised.

isCollapsed

isCollapsed: boolean

Gets or sets a value that determines whether this node is expanded or collapsed.

isDisabled

isDisabled: boolean

Gets or sets a value that determines whether this node is disabled.

Disabled nodes cannot get mouse or keyboard events.

If the collapseWhenDisabled proprety is set to true, disabling a node also collapses it.

isSelected

isSelected: boolean

Gets a value that determines whether this node is selected or not.

itemsSource

itemsSource: any[]

Gets the array that contains the items for this TreeNode.

This property is read-only. It returns an array that is a member of the parent TreeView's TreeView.itemsSource array.

level

level: number

Gets this node's level.

Top-level nodes have level zero.

nodes

nodes: TreeNode[]

Gets an array containing this node's child nodes.

This property returns null if the node has no children.

parentNode

parentNode: TreeNode

Gets this node's parent node.

This property returns null for top-level nodes.

treeView

treeView: TreeView

Gets a reference to the TreeView that contains this node.

Methods

addChildNode

  • addChildNode(index: number, dataItem: any): TreeNode
  • Adds a child node at a specific position.

    Parameters

    • index: number

      Index of the new child node.

    • dataItem: any

      Data item used to create the new node.

    Returns TreeNode

    The TreeNode that was added.

deSelect

  • deSelect(isSilent?: boolean): void
  • Deselects this node

    Parameters

    • Optional isSilent: boolean

    Returns void

ensureVisible

  • ensureVisible(): void
  • Ensures that a node is visible by expanding any collapsed ancestors and scrolling the element into view.

    Returns void

equals

  • Checks whether this node refers to the same element as another node.

    Parameters

    • node: TreeNode

      @TreeNode to compare with this one.

    Returns boolean

move

  • Moves this TreeNode to a new position on the TreeView.

    Parameters

    • refNode: any

      Reference TreeNode that defines the location where the node will be moved.

    • position: DropPosition

      Whether to move the node before, after, or into the reference node.

    Returns boolean

    True if the node was moved successfully.

next

  • next(visible?: boolean, enabled?: boolean): TreeNode
  • Gets a reference to the next node in the view.

    Parameters

    • Optional visible: boolean

      Whether to return only visible nodes (whose ancestors are not collapsed).

    • Optional enabled: boolean

      Whether to return only enabled nodes (whose ancestors are not disabled).

    Returns TreeNode

nextSibling

  • Gets a reference to the next sibling node in the view.

    Returns TreeNode

previous

  • previous(visible?: boolean, enabled?: boolean): TreeNode
  • Gets a reference to the previous node in the view.

    Parameters

    • Optional visible: boolean

      Whether to return only visible nodes (whose ancestors are not collapsed).

    • Optional enabled: boolean

      Whether to return only enabled nodes (whose ancestors are not disabled).

    Returns TreeNode

previousSibling

  • Gets a reference to the previous sibling node in the view.

    Returns TreeNode

refresh

  • refresh(dataItem?: any): void
  • Refreshes a node to reflect data changes.

    Parameters

    • Optional dataItem: any

      New node data. If not provided, the node is refreshed based on its original data item (which presumably has been updated).

    Returns void

remove

  • remove(): void

select

  • select(isSilent?: boolean): void
  • Selects this node.

    Parameters

    • Optional isSilent: boolean

    Returns void

setChecked

  • setChecked(checked: boolean, updateParent?: boolean): void
  • Sets the checked state of this node and its children.

    Parameters

    • checked: boolean

      Whether to check or uncheck the node and its children.

    • Optional updateParent: boolean

      Whether to update the checked state of this node's ancestor nodes.

    Returns void

setCollapsed

  • setCollapsed(collapsed: boolean, animate?: boolean, collapseSiblings?: boolean): void
  • Sets the collapsed state of the node.

    Parameters

    • collapsed: boolean

      Whether to collapse or expand the node.

    • Optional animate: boolean

      Whether to use animation when applying the new state.

    • Optional collapseSiblings: boolean

      Whether to collapse sibling nodes when expanding this node.

    Returns void