A single tree node.

NOTE:
Generally you should not modify properties directly, since this may break the internal bookkeeping.

Constructors

Properties

_errorInfo: any = null
_filterAutoExpanded?: boolean
_isLoading: boolean = false
_partload: boolean = false
_partsel: boolean = false
_requestId: number = 0
_rowElem: undefined | HTMLDivElement = undefined
_rowIdx: undefined | number = 0
checkbox?: CheckboxOption

Render a checkbox or radio button

children: null | WunderbaumNode[] = null

Array of child nodes (null for leaf nodes). For lazy nodes, this is null or ùndefineduntil the children are loaded and leaf nodes may be[]` (empty array).

classes: null | Set<string> = null

Additional classes added to div.wb-row.

colspan?: boolean

If true, (in grid mode) no cells are rendered, except for the node title.

data: any = {}

Custom data that was passed to the constructor

expanded?: boolean

Expansion state.

icon?: IconOption

Icon definition.

iconTooltip?: TooltipOption

Icon tooltip definition (true: use node's title).

key: string

Unique key. Passed with constructor or defaults to SEQUENCE.

Use setKey to modify.

lazy?: boolean

Lazy loading flag.

match?: boolean

Parent node (null for the invisible root node tree.root).

radiogroup?: boolean

If true, this node's children are considerd radio buttons.

isRadio.

refKey: undefined | string = undefined

Reference key. Unlike key, a refKey may occur multiple times within a tree (in this case we have 'clone nodes').

Use setKey to modify.

selected?: boolean

Selection state.

statusNodeType?: NodeStatusType
subMatchCount?: number = 0
title: string

Name of the node.

Use setTitle to modify.

titleWithHighlight?: string
tooltip?: TooltipOption

Tooltip definition (true: use node's title).

Reference to owning tree.

type?: string

Node type (used for styling).

unselectable?: boolean
sequence: number = 0

Methods

  • Internal

    Return true if at least on selectable descendant end-node is unselected.

    Returns boolean

  • Call event handler if defined in tree.options. Example:

    node._callEvent("edit.beforeEdit", {foo: 42})
    

    Parameters

    • type: string
    • Optionalextra: any

    Returns any

  • Parameters

    • source: any

    Returns Promise<any>

  • Find all descendant nodes that match condition (excluding self).

    If match is a string, search for exact node title. If match is a RegExp expression, apply it to node.title, using RegExp.test(). If match is a callback, match all nodes for that the callback(node) returns true.

    Returns an empty array if no nodes were found.

    Examples:

    // Match all node titles that match exactly 'Joe':
    nodeList = node.findAll("Joe")
    // Match all node titles that start with 'Joe' case sensitive:
    nodeList = node.findAll(/^Joe/)
    // Match all node titles that contain 'oe', case insensitive:
    nodeList = node.findAll(/oe/i)
    // Match all nodes with `data.price` >= 99:
    nodeList = node.findAll((n) => {
    return n.data.price >= 99;
    })

    Parameters

    Returns WunderbaumNode[]

  • Fix selection status for multi-hier mode. Only end-nodes are considered to update the descendants branch and parents. Should be called after this node has loaded new children or after children have been modified using the API.

    Parameters

    Returns void

  • Return a multiline string representation of a node/subnode hierarchy. Mostly useful for debugging.

    Example:

    console.info(tree.getActiveNode().format((n)=>n.title));
    

    logs

    Books
    ├─ Art of War
    ╰─ Don Quixote

    Parameters

    Returns string

  • Return the <span class='wb-col'> element with a given index or id.

    Parameters

    • colIdx: string | number

    Returns null | HTMLSpanElement

  • Return node depth (starting with 1 for top level nodes).

    Returns number

  • Return an option value that has a default, but may be overridden by a callback or a node instance attribute.

    Evaluation sequence:

    • If tree.options.<name> is a callback that returns something, use that.
    • Else if node.<name> is defined, use that.
    • Else if tree.types[<node.type>] is a value, use that.
    • Else if tree.options.<name> is a value, use that.
    • Else use defaultValue.

    Parameters

    • name: string

      name of the option property (on node and tree)

    • OptionaldefaultValue: any

      return this if nothing else matched Wunderbaum.getOption

    Returns any

  • Return an array of all parent nodes (top-down).

    Parameters

    • includeRoot: boolean = false

      Include the invisible system root node.

    • includeSelf: boolean = false

      Include the node itself.

    Returns WunderbaumNode[]

  • Return a string representing the hierachical node path, e.g. "a/b/c".

    Parameters

    • includeSelf: boolean = true
    • part: (keyof WunderbaumNode) | NodeAnyCallback = "title"

      property name or callback

    • separator: string = "/"

    Returns string

  • Return an array of selected nodes.

    Parameters

    • stopOnParents: boolean = false

      only return the topmost selected node (useful with selectMode 'hier')

    Returns WunderbaumNode[]

  • Return true if node has children. Return undefined if not sure, i.e. the node is lazy and not yet loaded.

    Returns undefined | boolean

  • Return true if node has className set.

    Parameters

    • className: string

    Returns boolean

  • Return true if node ist the currently focused node.

    Returns boolean

    0.9.0

  • Return true if this node is the currently active tree node.

    Returns boolean

  • Return true if this node's refKey is used by at least one other node.

    Returns boolean

  • Return true if this node's title spans all columns, i.e. the node has no grid cells.

    Returns boolean

  • Return true if this node has children, i.e. the node is generally expandable. If andCollapsed is set, we also check if this node is collapsed, i.e. an expand operation is currently possible.

    Parameters

    • andCollapsed: boolean = false

    Returns boolean

  • Return true if this node is currently expanded.

    Returns boolean

  • Return true if this node is the first node of its parent's children.

    Returns boolean

  • Return true if this node is the last node of its parent's children.

    Returns boolean

  • Return true if this node is lazy (even if data was already loaded)

    Returns boolean

  • Return true if node is lazy and loaded. For non-lazy nodes always return true.

    Returns boolean

  • Return true if node is currently loading, i.e. a GET request is pending.

    Returns boolean

  • [ext-filter] Return true if this node is matched by current filter (or no filter is active).

    Returns boolean

  • Return true if this node is a temporarily generated status node of type 'paging'.

    Returns boolean

  • (experimental) Return true if this node is partially loaded.

    Returns boolean

  • Return true if this node is partially selected (tri-state).

    Returns boolean

  • Return true if this node has DOM representaion, i.e. is displayed in the viewport.

    Returns boolean

  • Return true if this node has DOM representaion, i.e. is displayed in the viewport.

    Returns boolean

  • Return true if this node is a temporarily generated system node like 'loading', 'paging', or 'error' (node.statusNodeType contains the type).

    Returns boolean

  • Return true if this a top level node, i.e. a direct child of the (invisible) system root node.

    Returns boolean

  • Return true if node is marked lazy but not yet loaded. For non-lazy nodes always return false.

    Returns boolean

  • Return true if all parent nodes are expanded. Note: this does not check whether the node is scrolled into the visible part of the screen or viewport.

    Returns boolean

  • Load content of a lazy node. If the node is already loaded, nothing happens.

    Parameters

    • OptionalforceReload: boolean = false

      If true, reload even if already loaded.

    Returns Promise<void>

  • Write to console.debug with node name as prefix if opts.debugLevel >= 4 and browser console level includes debug/verbose messages.

    Parameters

    • ...args: any[]

    Returns void

  • Write to console.error with node name as prefix if opts.debugLevel >= 1.

    Parameters

    • ...args: any[]

    Returns void

  • Write to console.info with node name as prefix if opts.debugLevel >= 3.

    Parameters

    • ...args: any[]

    Returns void

  • Write to console.warn with node name as prefix if opts.debugLevel >= 2.

    Parameters

    • ...args: any[]

    Returns void

  • Expand all parents and optionally scroll into visible area as neccessary. Promise is resolved, when lazy loading and animations are done.

    Parameters

    • Optionaloptions: MakeVisibleOptions

      passed to setExpanded(). Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}

    Returns Promise<unknown>

  • Set focus relative to this node and optionally activate.

    'left' collapses the node if it is expanded, or move to the parent otherwise. 'right' expands the node if it is collapsed, or move to the first child otherwise.

    Parameters

    • where: string

      'down', 'first', 'last', 'left', 'parent', 'right', or 'up'. (Alternatively the event.key that would normally trigger this move, e.g. ArrowLeft = 'left'.

    • Optionaloptions: NavigateOptions

    Returns Promise<void | WunderbaumNode>

  • Remove all descendants of this node.

    Returns void

  • Remove all HTML markup from the DOM.

    Returns void

  • Remove all children, collapse, and set the lazy-flag, so that the lazyLoad event is triggered on next expand.

    Returns void

  • Renumber nodes _nativeIndex. This is useful to allow to restore the order after sorting a column. This method is automatically called after loading new child nodes.

    Parameters

    Returns void

    0.11.0

  • Activate this node, deactivate previous, send events, activate column and scroll into viewport.

    Parameters

    Returns Promise<void>

  • Add/remove one or more classes to <div class='wb-row'>.

    This also maintains node.classes, so the class will survive a re-render.

    Parameters

    • className: string | string[] | Set<string>

      one or more class names. Multiple classes can be passed as space-separated string, array of strings, or set of strings.

    • flag: boolean = true

    Returns void

  • Set keyboard focus here.

    Parameters

    • flag: boolean = true

    Returns void

  • Set a new icon path or class.

    Parameters

    • icon: string

    Returns void

  • Change node's key and/or refKey.

    Parameters

    • key: null | string
    • refKey: null | string

    Returns void

  • Rename this node.

    Parameters

    • title: string

    Returns void

  • Sort child list by title or custom criteria.

    Parameters

    • cmp: null | SortCallback = nodeTitleSorter

      custom compare function(a, b) that returns -1, 0, or 1 (defaults to sorting by title).

    • deep: boolean = false

      pass true to sort all descendant nodes recursively

    Returns void

  • Start editing this node's title.

    Returns void

  • Internal

    Return readable string representation for this instance.

    Returns string

  • Trigger modifyChild event on node.parent(!).

    Parameters

    • operation: string

      Type of change: 'add', 'remove', 'rename', 'move', 'data', ...

    • Optionalextra: any

    Returns void

  • Trigger modifyChild event on a parent to signal that a child was modified.

    Parameters

    • operation: string

      Type of change: 'add', 'remove', 'rename', 'move', 'data', ...

    • child: null | WunderbaumNode
    • Optionalextra: any

    Returns void

  • Trigger a repaint, typically after a status or data change.

    change defaults to 'data', which handles modifcations of title, icon, and column content. It can be reduced to 'ChangeType.status' if only active/focus/selected state has changed.

    This method will eventually call WunderbaumNode._render with default options, but may be more consistent with the tree's Wunderbaum.update API.

    Parameters

    Returns void

  • Call fn(node) for all parent nodes, bottom-up, including invisible system root.
    Stop iteration, if callback() returns false.
    Return false if iteration was stopped.

    Parameters

    • callback: (node: WunderbaumNode) => boolean | void

      the callback function. Return false to stop iteration

    • includeSelf: boolean = false

    Returns boolean

  • Call fn(node) for all sibling nodes.
    Stop iteration, if fn() returns false.
    Return false if iteration was stopped.

    Parameters

    • callback: (node: WunderbaumNode) => boolean | void

      the callback function. Return false to stop iteration.

    • includeSelf: boolean = false

      include this node in the iteration.

    Returns boolean