Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BSTreeView

This class allows to create and represent the TreeView element.

Hierarchy

  • BSTreeView

Index

Constructors

constructor

Properties

Private _checkedNodes

_checkedNodes: BSTreeViewNode[]
internal

Private _css

_css: string = ".treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}"
internal

Private _element

_element: HTMLElement
internal
param

HTMLElement this tree applies to

Private _elementId

_elementId: string

{string}

internal

Private _initialized

_initialized: boolean

Whether this treeview was already initialized

internal

Private _nodes

_nodes: Map<string, BSTreeViewNode>

A flat list representation of all nodes (unsorted)

internal

Private _options

The options used to initialize this treeView

internal

Private _orderedNodes

_orderedNodes: Map<string, BSTreeViewNode>

A flat list representation of all nodes, sorted by their nodeId, which gives you the render order

internal

Private _styleId

_styleId: string
internal

Private _tree

The hierarchically tree of nodes

internal

Private _wrapper

_wrapper: HTMLElement | null
internal

The wrapper in which the tree resides (normally an

    element)

Methods

Private _buildStyle

  • _buildStyle(): string
  • Construct the tree style CSS based on user options

    internal

    Returns string

Private _clickHandler

  • _clickHandler(event: Event): void
  • This function is called when a node is clicked. The respective action is triggered depending on the type of the event target

    internal

    Parameters

    • event: Event

    Returns void

Private _destroy

  • _destroy(): void

Private _diffArray

  • _diffArray<T>(a: Array<T>, b: Array<T>): T[]

Private _domToNode

  • Looks up the DOM for the closest parent list item to retrieve the data attribute nodeid, which is used to look up the node in the flattened structure.

    internal

    Parameters

    • target: HTMLElement

      The element that should be searched for

    Returns BSTreeViewNode

Private _expandLevels

Private _findNodes

  • _findNodes(pattern: string, attribute?: string, modifier?: string): BSTreeViewNode[]
  • Find nodes that match a given criteria

    internal

    Parameters

    • pattern: string

      A given string to match against

    • Default value attribute: string = "text"

      Attribute to compare pattern against

    • Default value modifier: string = "g"

      Valid RegEx modifiers

    Returns BSTreeViewNode[]

    nodes - Nodes that match your criteria

Private _getNodeValue

  • _getNodeValue(obj: object, attr: string): string
  • Recursive find for retrieving nested attributes values All values are return as strings, unless invalid

    internal

    Parameters

    • obj: object

      Typically a node, could be any object

    • attr: string

      Identifies an object property using dot notation

    Returns string

    value - Matching attributes string representation

Private _inheritCheckboxChanges

  • _inheritCheckboxChanges(): void
  • This function updates the list of checked nodes (see this._checkedNodes)

    internal

    Returns void

Private _init

Private _injectStyle

  • _injectStyle(): void

Private _load

Private _loadLocalData

Private _loadRemoteData

Private _registerNode

  • Register the given node at this tree view. This is called in BSTreeViewNode::_updateChildHierarchy

    internal

    Parameters

    Returns void

Private _render

  • _render(): void
  • Render the treeview and trigger EVENT_TRIGGERED at the end

    internal

    Returns void

Private _sortNodes

  • Sort an unsorted flat representation of the tree by their nodeId. This gives a flat list in the order which can be rendered

    internal

    Parameters

    Returns Map<string, BSTreeViewNode>

Private _subscribeEvents

  • _subscribeEvents(): void
  • Subscribe the events for this treeView. This includes the onEvent listeners passed by options and the click handler

    internal

    Returns void

Private _triggerEvent

Private _unsubscribeEvents

  • _unsubscribeEvents(): void
  • Unsubscribe the events for this treeView. This includes the onEvent listeners passed by options and the click handler

    internal

    Returns void

Private _updateFlatTreeMaps

  • _updateFlatTreeMaps(): void
  • Call this function after changes to the tree have been made to regenerate the flat structures

    internal

    Returns void

addNode

  • Add nodes to the tree, at the specified position of parent

    Parameters

    • nodes: BSTreeViewNode[] | BSTreeViewNode

      An array of nodes to add

    • Default value parentNode: BSTreeViewNode | null = null

      The node to which nodes will be added as children. Set null if it should be added to the root.

    • Default value index: number = null

      Zero based insert index, where the node will be inserted. If not specified, the node will be added to the end of the list.

    • Default value options: Partial<BSTreeViewMethodOptions> = new BSTreeViewMethodOptions()

    Returns this

addNodeAfter

addNodeBefore

checkAll

checkNode

clearSearch

collapseAll

collapseNode

disableAll

disableNode

enableAll

enableNode

expandAll

expandNode

findNodes

  • Returns an array of matching node objects.

    Parameters

    • pattern: string

      A pattern to match against a given field

    • field: string

    Returns BSTreeViewNode[]

    field - Field to query pattern against

getChecked

getCollapsed

getConfig

getDisabled

getEnabled

getExpanded

getNodes

getNodesCount

  • getNodesCount(): number
  • Returns the number of all nodes in the treeView (including all children)

    Returns number

getParents

getRootNodes

getRootNodesCount

  • getRootNodesCount(): number

getSearchResults

getSelected

getSiblings

getTreeElement

  • getTreeElement(): HTMLElement
  • Returns the dom element to which the treeview is attached to

    Returns HTMLElement

getUnchecked

getUnselected

remove

  • remove(): void

removeNode

revealNode

search

  • Searches the tree for nodes (text) that match given criteria

    Parameters

    • pattern: string

      A given string to match against

    • Default value options: Partial<BSTreeSearchOptions> = new BSTreeSearchOptions()

      Search criteria options

    Returns BSTreeViewNode[]

    nodes - Matching nodes

selectAll

selectNode

toggleNodeChecked

toggleNodeDisabled

toggleNodeExpanded

toggleNodeSelected

uncheckAll

uncheckNode

unmarkCheckboxChanges

  • unmarkCheckboxChanges(): this
  • Saves the current state of checkboxes as default, cleaning up any highlighted changes

    Returns this

unselectAll

unselectNode

updateNode

Generated using TypeDoc