A persistent plain object or array.

See also WunderbaumOptions.

Constructors

Properties

_cellNavMode: boolean = false
_util: util = util

Expose some useful methods of the util.ts module as tree._util.

activeColIdx: number = 0

Use setColumn()/getActiveColElem() to access.

Show/hide a checkbox or radiobutton.

columns: ColumnDefinitionList = []

List of column definitions.

data: {
    [key: string]: any;
} = {}

Contains additional data that was sent as response to an Ajax source load request.

Type declaration

  • [key: string]: any
element: HTMLDivElement

The div container element that was passed to the constructor.

filterMode: FilterModeType = null

Filter options (used as defaults for calls to Wunderbaum.filterNodes )

headerElement: HTMLDivElement

The div.wb-header element if any.

Show/hide a node icon.

iconTooltip?: DynamicStringOption

Show/hide a tooltip for the node icon.

id: string

Unique tree ID as passed to constructor. Defaults to "wb_SEQUENCE".

lastQuicksearchTerm: string = ""
lastQuicksearchTime: number = 0
listContainerElement: HTMLDivElement

The div.wb-list-container element that contains the nodeListElement.

nodeListElement: HTMLDivElement

The div.wb-node-list element that contains all visible div.wb-row child elements.

Merged options from constructor args and tree- and extension defaults.

ready: Promise<any>

A Promise that is resolved when the tree was initialized (similar to init(e) event).

The invisible root node, that holds all visible top level nodes.

Show/hide a tooltip.

Shared properties, referenced by node.type.

unselectable?: DynamicBoolOption

Define a node checkbox as readonly.

util: util = util

Expose some useful methods of the util.ts module as Wunderbaum.util.

version: string = "@VERSION"

Wunderbaum release version number "MAJOR.MINOR.PATCH".

Accessors

  • get iconMap(): {
        [key: string]: string;
    }
  • Return the icon-function -> icon-definition mapping.

    Returns {
        [key: string]: string;
    }

    • [key: string]: string

Methods

  • Call event handler if defined in tree or tree.EXTENSION options.

    Example:

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

    Parameters

    • type: string
    • Optional extra: any

    Returns any

  • Call tree method or extension method if defined.

    Example:

    tree._callMethod("edit.startEdit", "arg1", "arg2")
    

    Parameters

    • name: string
    • Rest ...args: any[]

    Returns any

  • Update column headers and column width. Return true if at least one column width changed.

    Returns boolean

  • Return the number of nodes in the data model.

    Parameters

    • visible: boolean = false

      if true, nodes that are hidden due to collapsed parents are ignored.

    Returns number

  • Clear nodes and markup and detach events and observers.

    This method may be useful to free up resources before re-creating a tree on an existing div, for example in unittest suites. Note that this Wunderbaum instance becomes unusable afterwards.

    Returns void

  • Disable render requests during operations that would trigger many updates.

    try {
    tree.enableUpdate(false);
    // ... (long running operation that would trigger many updates)
    foo();
    // ... NOTE: make sure that async operations have finished, e.g.
    await foo();
    } finally {
    tree.enableUpdate(true);
    }

    Parameters

    • flag: boolean

    Returns void

  • Recursively expand all expandable nodes (triggers lazy load if needed).

    Parameters

    Returns Promise<void>

  • Dim or hide unmatched nodes.

    Parameters

    • filter: string | RegExp | NodeFilterCallback

      a string to match against node titles, or a callback function.

    • options: FilterNodesOptions

      filter options. Defaults to the tree.options.filter settings.

    Returns number

    the number of nodes that match the filter.

    Example

    tree.filterNodes("foo", {mode: 'dim', fuzzy: true});
    // or pass a callback
    tree.filterNodes((node) => { return node.data.foo === true }, {mode: 'hide'});
  • Find a node relative to another node.

    Parameters

    • node: WunderbaumNode
    • where: string

      'down', 'first', 'last', 'left', 'parent', 'right', or 'up'. (Alternatively the keyCode that would normally trigger this move, e.g. $.ui.keyCode.LEFT = 'left'.

    • includeHidden: boolean = false

      Not yet implemented

    Returns undefined | null | WunderbaumNode

  • Return multiline string representation of the node hierarchy. Mostly useful for debugging.

    Example:

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

    logs

    Playground
    ├─ Books
    | ├─ Art of War
    | ╰─ Don Quixote
    ├─ Music
    ...

    Parameters

    Returns string

  • Return the active cell (span.wb-col) of the currently active node or null.

    Returns null | HTMLSpanElement

  • Return tree.option.NAME (also resolving if this is a callback).

    See also WunderbaumNode.getOption() to evaluate node.NAME setting and tree.types[node.type].NAME.

    Parameters

    • name: string

      option name (use dot notation to access extension option, e.g. filter.mode)

    • Optional defaultValue: any

    Returns any

  • 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 the tree (or one of its nodes) has the input focus.

    Returns boolean

  • Return true if the tree displays a header. Grids have a header unless the header option is set to false. Plain trees have a header if the header option is a string or true.

    Returns boolean

  • Return true if cell-navigation mode is active.

    Returns boolean

  • Return true if a filter is currently applied.

    Returns boolean

  • Return true if tree has more than one column, i.e. has additional data columns.

    Returns boolean

  • Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.

    Returns boolean

  • Return true if row-navigation mode is active.

    Returns boolean

  • Reload the tree with a new source.

    Previous data is cleared. Note that also column- and type defintions may be passed with the source object.

    Parameters

    Returns Promise<void>

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

    Parameters

    • Rest ...args: any[]

    Returns void

  • Write to console.error with tree name as prefix.

    Parameters

    • Rest ...args: any[]

    Returns void

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

    Parameters

    • Rest ...args: any[]

    Returns void

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

    Parameters

    • Rest ...args: any[]

    Returns void

  • Run code, but defer rendering of viewport until done.

    tree.runWithDeferredUpdate(() => {
    return someFuncThatWouldUpdateManyNodes();
    });

    Parameters

    • func: (() => any)
        • (): any
        • Returns any

    • hint: null = null

    Returns any

  • Make sure that this node is vertically scrolled into the viewport.

    Nodes that are above the visible area become the top row, nodes that are below the viewport become the bottom row.

    Parameters

    Returns void

  • Set or remove keyboard focus to the tree container.

    Parameters

    Returns void

  • Set the tree's navigation mode.

    Parameters

    • flag: boolean = true

    Returns void

  • Set column #colIdx to 'active'.

    This higlights the column header and -cells by adding the wb-active class to all grid cells of the active column.
    Available in cell-nav mode only.

    If options.edit is true, the embedded input element is focused, or if colIdx is 0, the node title is put into edit mode.

    Parameters

    Returns void

  • Disable mouse and keyboard interaction (return prev. state).

    Parameters

    • flag: boolean = true

    Returns boolean

  • Set or remove keyboard focus to the tree container.

    Parameters

    • flag: boolean = true

    Returns void

  • Set the tree's navigation mode option.

    Parameters

    Returns void

  • Set tree option. Use dot notation to set plugin option, e.g. "filter.mode".

    Parameters

    • name: string
    • value: any

    Returns void

  • Add or redefine node type definitions.

    Parameters

    • types: any
    • replace: boolean = true

    Returns void

  • Sort nodes 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

  • Internal

    Return readable string representation for this instance.

    Returns string

  • Render pending changes that were scheduled using WunderbaumNode.update if any.

    This is hardly ever neccessary, since we normally either

    • call update(ChangeType.TYPE) (async, throttled), or
    • call update(ChangeType.TYPE, {immediate: true}) (synchronous)

    updatePendingModifications() will only force immediate execution of pending async changes if any.

    Returns void

  • Call callback(node) for all nodes in vertical order, top down (or bottom up).

    Note that this considers expansion state, i.e. filtered nodes and children of collapsed nodes are skipped, unless includeHidden is set.

    Stop iteration if callback() returns false.
    Return false if iteration was stopped.

    Parameters

    Returns boolean

    false if iteration was canceled

  • Return a {node: WunderbaumNode, region: TYPE} object for a mouse event.

    Parameters

    • event: Event

      Mouse event, e.g. click, ...

    Returns WbEventInfo

    Return a {node: WunderbaumNode, region: TYPE} object TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined

  • Return a Wunderbaum instance, from element, id, index, or event.

    getTree();         // Get first Wunderbaum instance on page
    getTree(1); // Get second Wunderbaum instance on page
    getTree(event); // Get tree for this mouse- or keyboard event
    getTree("foo"); // Get tree for this `tree.options.id`
    getTree("#tree"); // Get tree for first matching element selector

    Parameters

    Returns null | Wunderbaum