# Class TreeDataSource<Data, RootParameters, NodeParameters>

#### Type Parameters

- Data extends WithIdentifier & WithChildren = any
- RootParameters = any
- NodeParameters = any

#### Hierarchy

- BaseDataSource<Node<Data>[], TreeDataSourceMetadata>
  - TreeDataSource

#### Implements

- OnInit

- Defined in tree/src/lib/tree.data-source.ts:238

#####
Index

### Constructors

constructor

### Properties

__id
_connectedViewer
_connectedViewerTeardown
_data?
_data$
_expandedLocalStorageSubscription
_initialised
_lastRefreshed
_nodeParameters
_preSelected
_refreshMatchFilter
_retry$
_selectedLocalStorageSubscription
_viewerIds
applyFilterMethod
change$
childrenRemoteMethod
destroyed$
error$
expanded
getIcon
getStyle
getType
hasDetails
hasError?
hasError$
initialised$
interceptors
loading?
loading$
matchFilter
metadata
rootRemoteMethod
searchForm
selected
toDisplay
tree$
treeControl
destroyed$
initialised$
instances

### Accessors

data
hasConnections
id
lastRefreshed
nodeParameters

### Methods

_connect
_disconnect
applyMetadata
attach
collapseNode
connect
derive
deselectNode
destroy
disconnect
expandNode
flatTree
genericRetryFunction
getChildren
getMetadata
getNodeById
getRoot
getRootParameters
getTreeRoot
getViewerId
handelError
init
initExpanded
initSelected
isConnected
ngOnDestroy
ngOnInit
refresh
refreshMatchFilter
reset
retry
selectNode
setGetIcon
setGetStyle
setGetType
setHasDetails
setMatchFilter
setToDisplay
setTreeControl
toJSON
toNode
toPromise
updateNodes
add
remove

## Constructors

### constructor

- new TreeDataSource<Data, RootParameters, NodeParameters>(rootRemoteMethod, childrenRemoteMethod?, applyFilterMethod?, metadata?): TreeDataSource<Data, RootParameters, NodeParameters>

- #### Type Parameters

  - Data extends unknown = any
  - RootParameters = any
  - NodeParameters = any

  #### Parameters

  - rootRemoteMethod: Method<Data | Data[], RootParameters>
  - childrenRemoteMethod: Method<Data[], Node<Data, any>> = null
  - applyFilterMethod: Method<Node<Data, any>[], TreeApplyFilterParameter<ISearchForm<unknown>, any>> = null
  - metadata: TreeDataSourceMetadata = null

  #### Returns TreeDataSource<Data, RootParameters, NodeParameters>

  Overrides BaseDataSource<Array<Node<Data>>, TreeDataSourceMetadata>.constructor

  - Defined in tree/src/lib/tree.data-source.ts:258

## Properties

### `Internal` __id

__id: string = ...

unique internal id

Inherited from BaseDataSource.__id

- Defined in definition/src/lib/definition.ts:61

### `Protected` _connectedViewer

_connectedViewer: Map<string, Observable<Node<Data, any>[]>> = ...

Inherited from BaseDataSource._connectedViewer

- Defined in data-source/src/lib/base.data-source.ts:78

### `Protected` _connectedViewerTeardown

_connectedViewerTeardown: Map<string, TeardownLogic> = ...

Inherited from BaseDataSource._connectedViewerTeardown

- Defined in data-source/src/lib/base.data-source.ts:79

### `Protected` `Optional` _data

_data?: Node<Data, any>[]

Inherited from BaseDataSource._data

- Defined in data-source/src/lib/base.data-source.ts:104

### `Protected` _data$

_data$: BehaviorSubject<Node<Data, any>[]> = ...

Overrides BaseDataSource._data$

- Defined in tree/src/lib/tree.data-source.ts:250

### `Private` _expandedLocalStorageSubscription

_expandedLocalStorageSubscription: Subscription = null

- Defined in tree/src/lib/tree.data-source.ts:251

### `Protected` _initialised

_initialised: boolean = false

Inherited from BaseDataSource._initialised

- Defined in definition/src/lib/definition.ts:62

### `Protected` _lastRefreshed

_lastRefreshed: Date = null

Inherited from BaseDataSource._lastRefreshed

- Defined in data-source/src/lib/base.data-source.ts:77

### `Private` _nodeParameters

_nodeParameters: NodeParameters = null

- Defined in tree/src/lib/tree.data-source.ts:278

### `Private` _preSelected

_preSelected: string[] = []

- Defined in tree/src/lib/tree.data-source.ts:254

### `Private` _refreshMatchFilter

_refreshMatchFilter: Subject<void> = ...

- Defined in tree/src/lib/tree.data-source.ts:255

### `Protected` _retry$

_retry$: Subject<void> = ...

Inherited from BaseDataSource._retry$

- Defined in data-source/src/lib/base.data-source.ts:90

### `Private` _selectedLocalStorageSubscription

_selectedLocalStorageSubscription: Subscription = null

- Defined in tree/src/lib/tree.data-source.ts:252

### `Protected` _viewerIds

_viewerIds: Map<BaseDataSourceViewer<any>, string> = ...

a map of viewer to view id. Allows to create a view id from the viewer object reference

Inherited from BaseDataSource._viewerIds

- Defined in data-source/src/lib/base.data-source.ts:89

### `Private` `Readonly` applyFilterMethod

applyFilterMethod: Method<Node<Data, any>[], TreeApplyFilterParameter<ISearchForm<unknown>, any>>

- Defined in tree/src/lib/tree.data-source.ts:256

### `Readonly` change$

change$: Subject<Node<Data, any>[]> = ...

Inherited from BaseDataSource.change$

- Defined in data-source/src/lib/base.data-source.ts:67

### `Readonly` childrenRemoteMethod

childrenRemoteMethod: Method<Data[], Node<Data, any>> = null

- Defined in tree/src/lib/tree.data-source.ts:263

### `Readonly` destroyed$

destroyed$: Subject<void> = ...

Emits if the data source is destroyed

Inherited from BaseDataSource.destroyed$

- Defined in definition/src/lib/definition.ts:48

### `Readonly` error$

error$: ReplaySubject<Error> = ...

Inherited from BaseDataSource.error$

- Defined in data-source/src/lib/base.data-source.ts:73

### expanded

expanded: SelectionModel<string>

- Defined in tree/src/lib/tree.data-source.ts:246

### getIcon

getIcon: NodeGetIconFunction<Data> = ...

- Defined in tree/src/lib/tree.data-source.ts:314

### getStyle

getStyle: NodeGetStyleFunction<Data> = ...

- Defined in tree/src/lib/tree.data-source.ts:318

### getType

getType: NodeGetTypeFunction<Data> = ...

- Defined in tree/src/lib/tree.data-source.ts:316

### hasDetails

hasDetails: NodeHasDetailsFunction<Data> = ...

- Defined in tree/src/lib/tree.data-source.ts:322

### `Optional` hasError

hasError?: Signal<boolean>

Inherited from BaseDataSource.hasError

- Defined in data-source/src/lib/base.data-source.ts:94

### `Readonly` hasError$

hasError$: ToggleSubject = ...

Inherited from BaseDataSource.hasError$

- Defined in data-source/src/lib/base.data-source.ts:72

### `Readonly` initialised$

initialised$: Subject<void> = ...

Emits if the data source is initialised

Inherited from BaseDataSource.initialised$

- Defined in definition/src/lib/definition.ts:52

### `Readonly` interceptors

interceptors: Set<Subject<any>> = ...

Inherited from BaseDataSource.interceptors

- Defined in definition/src/lib/definition.ts:53

### `Optional` loading

loading?: Signal<boolean>

Inherited from BaseDataSource.loading

- Defined in data-source/src/lib/base.data-source.ts:92

### loading$

loading$: ToggleSubject = ...

Overrides BaseDataSource.loading$

- Defined in tree/src/lib/tree.data-source.ts:248

### matchFilter

matchFilter: ((node) => boolean) = ...

#### Type declaration

- - (node): boolean

  - #### Parameters

    - node: Node<Data, any>

    #### Returns boolean

- Defined in tree/src/lib/tree.data-source.ts:324

### metadata

metadata: TreeDataSourceMetadata

Inherited from BaseDataSource.metadata

- Defined in definition/src/lib/definition.ts:44

### `Readonly` rootRemoteMethod

rootRemoteMethod: Method<Data | Data[], RootParameters>

- Defined in tree/src/lib/tree.data-source.ts:260

### searchForm

searchForm: SearchForm<unknown> = null

- Defined in tree/src/lib/tree.data-source.ts:249

### selected

selected: SelectionModel<Node<Data, any>>

- Defined in tree/src/lib/tree.data-source.ts:245

### toDisplay

toDisplay: NodeToDisplayFunction<Data> = ...

- Defined in tree/src/lib/tree.data-source.ts:311

### tree$

tree$: BehaviorSubject<Node<Data, any>[]> = ...

- Defined in tree/src/lib/tree.data-source.ts:243

### treeControl

treeControl: FlatTreeControl<Node<Data, any>, Node<Data, any>>

- Defined in tree/src/lib/tree.data-source.ts:244

### `Static` `Readonly` destroyed$

destroyed$: Subject<BaseDefinition<BaseDefinitionMetadata>> = ...

Emits when a new Definition instance is initialised

Inherited from BaseDataSource.destroyed$

- Defined in definition/src/lib/definition.ts:41

### `Static` `Readonly` initialised$

initialised$: Subject<BaseDefinition<BaseDefinitionMetadata>> = ...

Emits when a new Definition instance is initialised

Inherited from BaseDataSource.initialised$

- Defined in definition/src/lib/definition.ts:35

### `Static` `Readonly` instances

instances: Map<string, BaseDefinition<BaseDefinitionMetadata>> = ...

A map of active Definition instances

Inherited from BaseDataSource.instances

- Defined in definition/src/lib/definition.ts:27

## Accessors

### data

- get data(): Data

- #### Returns Data

  Inherited from BaseDataSource.data

  - Defined in data-source/src/lib/base.data-source.ts:106

### hasConnections

- get hasConnections(): boolean

- #### Returns boolean

  Inherited from BaseDataSource.hasConnections

  - Defined in data-source/src/lib/base.data-source.ts:110

### id

- get id(): string

- #### Returns string

  Inherited from BaseDataSource.id

  - Defined in definition/src/lib/definition.ts:87

### lastRefreshed

- get lastRefreshed(): Date

- #### Returns Date

  Inherited from BaseDataSource.lastRefreshed

  - Defined in data-source/src/lib/base.data-source.ts:74

### nodeParameters

- get nodeParameters(): NodeParameters

- #### Returns NodeParameters

  - Defined in tree/src/lib/tree.data-source.ts:280
- set nodeParameters(nodeParameters): void

- #### Parameters

  - nodeParameters: NodeParameters

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:284

## Methods

### `Protected` _connect

- _connect(collectionViewer): Observable<Node<Data, any>[]>

- #### Parameters

  - collectionViewer: Required<BaseDataSourceViewer<any>>

  #### Returns Observable<Node<Data, any>[]>

  Overrides BaseDataSource._connect

  - Defined in tree/src/lib/tree.data-source.ts:622

### `Protected` _disconnect

- _disconnect(viewerId): void

- #### Parameters

  - viewerId: string

  #### Returns void

  Inherited from BaseDataSource._disconnect

  - Defined in data-source/src/lib/base.data-source.ts:308

### applyMetadata

- applyMetadata(partialMetadata): void

- #### Parameters

  - partialMetadata: Partial<TreeDataSourceMetadata>

  #### Returns void

  Inherited from BaseDataSource.applyMetadata

  - Defined in definition/src/lib/definition.ts:111

### attach

- attach(viewerId): Observable<Node<Data, any>[]>

- #### Parameters

  - viewerId: string

  #### Returns Observable<Node<Data, any>[]>

  Inherited from BaseDataSource.attach

  - Defined in data-source/src/lib/base.data-source.ts:210

### collapseNode

- collapseNode(node, options?): Promise<void>

- #### Parameters

  - node: Node<Data, any>
  - `Optional` options: EventOptions

  #### Returns Promise<void>

  - Defined in tree/src/lib/tree.data-source.ts:510

### connect

- connect(viewerOrString): Observable<Node<Data, any>[]>

- #### Parameters

  - viewerOrString: string | BaseDataSourceViewer<any>

  #### Returns Observable<Node<Data, any>[]>

  Inherited from BaseDataSource.connect

  - Defined in data-source/src/lib/base.data-source.ts:124

### derive

- derive(id, metadata?): BaseDataSource<any, BaseDataSourceMetadata, BaseDataSourceViewer<any>>

- #### Parameters

  - id: string
  - metadata: Partial<BaseDataSourceMetadata> = ...

  #### Returns BaseDataSource<any, BaseDataSourceMetadata, BaseDataSourceViewer<any>>

  Inherited from BaseDataSource.derive

  - Defined in data-source/src/lib/base.data-source.ts:270

### deselectNode

- deselectNode(node): Promise<void>

- #### Parameters

  - node: Node<Data, any>

  #### Returns Promise<void>

  - Defined in tree/src/lib/tree.data-source.ts:400

### destroy

- destroy(): void

- #### Returns void

  Overrides BaseDataSource.destroy

  - Defined in tree/src/lib/tree.data-source.ts:538

### disconnect

- disconnect(viewerOrId): void

- #### Parameters

  - viewerOrId: string | BaseDataSourceViewer<any>

  #### Returns void

  Inherited from BaseDataSource.disconnect

  - Defined in data-source/src/lib/base.data-source.ts:225

### expandNode

- expandNode(node, options?): Promise<void>

- #### Parameters

  - node: Node<Data, any>
  - `Optional` options: EventOptions

  #### Returns Promise<void>

  - Defined in tree/src/lib/tree.data-source.ts:405

### flatTree

- flatTree(tree, all?): Node<Data, any>[]

- Converts the tree structure into a list.

  #### Parameters

  - tree: Node<Data, any>
  - all: boolean = false

    true - include nodes children that are not expanded

  #### Returns Node<Data, any>[]

  - Defined in tree/src/lib/tree.data-source.ts:534

### `Protected` genericRetryFunction

- genericRetryFunction(error, retryCount): Observable<any>

- #### Parameters

  - error: any
  - retryCount: number

  #### Returns Observable<any>

  Inherited from BaseDataSource.genericRetryFunction

  - Defined in data-source/src/lib/base.data-source.ts:311

### getChildren

- getChildren(node): Promise<Data[]>

- #### Parameters

  - node: Node<Data, any>

  #### Returns Promise<Data[]>

  - Defined in tree/src/lib/tree.data-source.ts:445

### getMetadata

- getMetadata(): TreeDataSourceMetadata

- #### Returns TreeDataSourceMetadata

  Inherited from BaseDataSource.getMetadata

  - Defined in definition/src/lib/definition.ts:107

### getNodeById

- getNodeById(id): Node<Data, any>

- #### Parameters

  - id: string

  #### Returns Node<Data, any>

  - Defined in tree/src/lib/tree.data-source.ts:465

### getRoot

- getRoot(options?): Promise<Data | Data[]>

- #### Parameters

  - options: {
    cache?: boolean;
    } = {}

    - ##### `Optional` cache?: boolean

  #### Returns Promise<Data | Data[]>

  - Defined in tree/src/lib/tree.data-source.ts:453

### getRootParameters

- getRootParameters(options?): Promise<RootParameters>

- #### Parameters

  - options: {
    cache?: boolean;
    } = {}

    - ##### `Optional` cache?: boolean

  #### Returns Promise<RootParameters>

  - Defined in tree/src/lib/tree.data-source.ts:458

### getTreeRoot

- getTreeRoot(options?): Promise<Node<Data, any>[]>

- #### Parameters

  - options: {
    cache?: boolean;
    } = {}

    - ##### `Optional` cache?: boolean

  #### Returns Promise<Node<Data, any>[]>

  - Defined in tree/src/lib/tree.data-source.ts:326

### getViewerId

- getViewerId(viewer): string

- #### Parameters

  - viewer: BaseDataSourceViewer<any>

  #### Returns string

  Inherited from BaseDataSource.getViewerId

  - Defined in data-source/src/lib/base.data-source.ts:114

### `Protected` handelError

- handelError(error): void

- #### Parameters

  - error: any

  #### Returns void

  Inherited from BaseDataSource.handelError

  - Defined in data-source/src/lib/base.data-source.ts:317

### init

- init(): void

- #### Returns void

  Inherited from BaseDataSource.init

  - Defined in definition/src/lib/definition.ts:127

### `Private` initExpanded

- initExpanded(): void

- #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:750

### `Private` initSelected

- initSelected(): void

- #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:720

### isConnected

- isConnected(viewerOrId): boolean

- #### Parameters

  - viewerOrId: string | BaseDataSourceViewer<any>

  #### Returns boolean

  Inherited from BaseDataSource.isConnected

  - Defined in data-source/src/lib/base.data-source.ts:217

### ngOnDestroy

- ngOnDestroy(): void

- #### Returns void

  Inherited from BaseDataSource.ngOnDestroy

  - Defined in definition/src/lib/definition.ts:122

### ngOnInit

- ngOnInit(): void

- #### Returns void

  Implementation of OnInit.ngOnInit

  - Defined in tree/src/lib/tree.data-source.ts:289

### refresh

- refresh(): Promise<any>

- #### Returns Promise<any>

  Overrides BaseDataSource.refresh

  - Defined in tree/src/lib/tree.data-source.ts:553

### refreshMatchFilter

- refreshMatchFilter(): void

- #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:549

### reset

- reset(): any

- #### Returns any

  Overrides BaseDataSource.reset

  - Defined in tree/src/lib/tree.data-source.ts:595

### retry

- retry(): any

- #### Returns any

  Inherited from BaseDataSource.retry

  - Defined in data-source/src/lib/base.data-source.ts:293

### selectNode

- selectNode(node): Promise<void>

- #### Parameters

  - node: Node<Data, any>

  #### Returns Promise<void>

  - Defined in tree/src/lib/tree.data-source.ts:364

### setGetIcon

- setGetIcon(getIcon?): void

- #### Parameters

  - getIcon: NodeGetIconFunction<Data> = ...

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:390

### setGetStyle

- setGetStyle(getStyle?): void

- #### Parameters

  - getStyle: NodeGetStyleFunction<any> = ...

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:601

### setGetType

- setGetType(getType?): void

- #### Parameters

  - getType: NodeGetTypeFunction<any> = ...

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:605

### setHasDetails

- setHasDetails(hasDetails?): void

- #### Parameters

  - hasDetails: NodeHasDetailsFunction<Data> = ...

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:394

### setMatchFilter

- setMatchFilter(matchFilter): void

- #### Parameters

  - matchFilter: ((node) => boolean)
    - - (node): boolean

      - #### Parameters

        - node: Node<Data, any>

        #### Returns boolean

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:380

### setToDisplay

- setToDisplay(toDisplay?): void

- #### Parameters

  - toDisplay: NodeToDisplayFunction<Data> = ...

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:384

### setTreeControl

- setTreeControl(treeControl): void

- #### Parameters

  - treeControl: FlatTreeControl<Node<Data, any>, Node<Data, any>>

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:376

### toJSON

- toJSON(): object

- #### Returns object

  Inherited from BaseDataSource.toJSON

  - Defined in data-source/src/lib/base.data-source.ts:280

### toNode

- toNode(parent, item, depth?, onExpand?, onCollapse?, onSelect?, onDeselect?): Promise<Node<Data, any>>

- #### Parameters

  - parent: Node<Data, any>
  - item: Data
  - depth: number = 0
  - onExpand: ExpandNodeFunction<Data> = ...
  - onCollapse: ExpandNodeFunction<Data> = ...
  - onSelect: ExpandNodeFunction<Data> = ...
  - onDeselect: ExpandNodeFunction<Data> = ...

  #### Returns Promise<Node<Data, any>>

  - Defined in tree/src/lib/tree.data-source.ts:484

### toPromise

- toPromise(viewer): Promise<Node<Data, any>[]>

- Creates a connection to tha data source and converts the Observable into a promise and then disconnects the viewer

  #### Parameters

  - viewer: BaseDataSourceViewer<any>

  #### Returns Promise<Node<Data, any>[]>

  Inherited from BaseDataSource.toPromise

  - Defined in data-source/src/lib/base.data-source.ts:264

### updateNodes

- updateNodes(): void

- recall the getStyle, getIcon and toDisplay methods and update the node objects

  #### Returns void

  - Defined in tree/src/lib/tree.data-source.ts:613

### `Static` add

- add(definition): void

- #### Parameters

  - definition: BaseDefinition<BaseDefinitionMetadata>

  #### Returns void

  Inherited from BaseDataSource.add

  - Defined in definition/src/lib/definition.ts:94

### `Static` remove

- remove(definition): void

- #### Parameters

  - definition: BaseDefinition<BaseDefinitionMetadata>

  #### Returns void

  Inherited from BaseDataSource.remove

  - Defined in definition/src/lib/definition.ts:102