Interface

HierarchicalTableDataSource

Hierarchical Table Data Source


Description

Lets a TableDataSource supply expandable rows.

Implement it in addition to TableDataSource to report which rows can be expanded, how deep each row sits in the hierarchy and what happens when the user opens or closes a row. The source stays responsible for the row count: after expanding or collapsing, it reports the rows that are visible now.

Methods

Name

Parameters

Returns

Shared

CollapseRowAt

row As Integer

ExpandRowAt

row As Integer

RowDepthAt

row As Integer

Integer

RowIsExpandableAt

row As Integer

Boolean

RowIsExpandedAt

row As Integer

Boolean

Method descriptions


HierarchicalTableDataSource.CollapseRowAt

CollapseRowAt(row As Integer)

Remove the row's children from the visible projection. Afterwards the source reports only the rows that are visible now, so the row count shrinks by the children that were removed.

This example removes every following row that sits deeper:

' Remove every following row that sits deeper than this one
Var depth As Integer = mRows(row).Depth

While row + 1 <= mRows.LastIndex And mRows(row + 1).Depth > depth
  mRows.RemoveAt(row + 1)
Wend

mRows(row).Expanded = False

HierarchicalTableDataSource.ExpandRowAt

ExpandRowAt(row As Integer)

Insert the row's children directly after row. The children become rows of their own, so the row count grows and the rows below move down.

This example inserts the children directly below their parent:

' The children become rows of their own, directly below their parent
Var children() As Record = ChildrenOf(mRows(row))

For i As Integer = children.LastIndex DownTo 0
  mRows.AddAt(row + 1, children(i))
Next

mRows(row).Expanded = True

HierarchicalTableDataSource.RowDepthAt

RowDepthAt(row As Integer) As Integer

Indentation depth, 0 = top level. It is what the table indents by, so a child sits one level deeper than its parent.

This example reports the depth the record sits at:

Return mRows(row).Depth

HierarchicalTableDataSource.RowIsExpandableAt

RowIsExpandableAt(row As Integer) As Boolean

Whether the row shows a disclosure widget. Only a row that says True here can be opened by the user.

This example reports whether the record has children:

Return mRows(row).HasChildren

HierarchicalTableDataSource.RowIsExpandedAt

RowIsExpandedAt(row As Integer) As Boolean

Whether the row is currently expanded. The table asks while drawing, so the widget always matches what the source reports.

This example reports the state the record carries:

Return mRows(row).Expanded

Compatibility

Project Types

Desktop

Operating Systems

All