EhLib
ContentsIndexHome
PreviousUpNext
Storing records in tree mode (TreeView)

In tree mode the TMemTableEh create node objects (TMemRecViewEh type) for each record in the internal array. Node object have reference to parent record (Rec property) and has a list of child nodes (NodeItems). 

Adjusting TreeView mode is realized by subproperties of TMemTableEh.TreeList property. TMemTableEh automatically adds new record in the tree, using field values defined by TreeList.KeyFieldName and TreeList.RefParentFieldName properties. When new record is appearances in MemTable, it tries to find Parent record in the list of existing records, it looks throw records trying to find values of the field in KeyFieldName that is equal to the value of the field defined by RefParentFieldName property in the new record. Furthermore, it checks, if this record is a parent for other existing records in array. Building of tree can be speeding up, if you create indexes for fields specified in TreeList.KeyFieldName and TreeList.RefParentFieldName properties. However the maximum speed of building tree is possible to achieve if the records all records will be appended in DataSet in valid sequence. In other words every record must be added in DataSet in same order as it appears in the tree. In last case it is not recommended to create indexes, it can only slow down building of tree. If records appear in DataSet in valid order set FullBuildCheck to False. It will not check if the new record have child records in DataSet. 

Sub-properties of TMemTableEh.TreeList property:

Property name 
Property type 
Description 
Active 
Boolean 
Defines that TreeView mode is active. In TreeView mode you can access TMemTableEh properties: TreeNodeLevel, TreeNodeExpanded, TreeNodeHasChildren, TreeNodeChildCount for current record. 
KeyFieldName 
String 
Holds a name of the key field of record. Child record will refer to parental record with the key determined by the KeyFieldName field. 
RefParentFieldName 
String 
Holds a name of the field that contain reference value to a parent record. 
DefaultNodeExpanded 
Boolean 
Defines a value of Expanded property for new elements of the tree. 
DefaultNodeHasChildren 
Boolean 
Defines a value of HasChildren property for a new elements of the tree. 
FullBuildCheck 
Boolean 
Defines if need check if there are Child records in array for new record. Setting this property to False can speed up building of tree, but all child records must be added after parent record. 

 

Use next TMemTableEh properties to access state of the tree node for the current record of DataSet:

Property name 
Property type 
Description 
RecView 
TMemRecViewEh 
a reference to the tree node of the tree, it is available only in tree mode. 
TreeNodeLevel 
Integer 
the level of the node in the tree. 
TreeNodeExpanded 
Boolean 
Specifies whether the tree node is expanded. 
TreeNodeHasChildren 
Boolean 
Indicates whether a node has any children. 
TreeNodeChildCount 
Integer 
An amount of Child elements. 
Copyright (c) 1998-2013. All rights reserved.
What do you think about this topic? Send feedback!