See Also

Enumerations

Name Values
This class exposes no enumerations.

Constants

Name Value
This class exposes no constants.

Events

Definition Description
ContextClick( theItem as GraffitiWebTreeItem, mouseX as Integer, mouseY as Integer ) Fires when the user right-clicks an item in the display. mouseX and mouseY are relative to the page, not the control.
ItemChecked( theItem as GraffitiWebTreeItem ) Fires when the user checks an item in the display.
ItemClicked( theItem as GraffitiWebTreeItem ) Fires when the user has clicked an item.
ItemCollapsed( theItem as GraffitiWebTreeItem ) Fires when the user has collapsed an expandable item.
ItemDoubleClicked( theItem as GraffitiWebTreeItem ) Fires when the user has double-clicked an item.
ItemEdited( theItem as GraffitiWebTreeItem ) Fires when the user has finished editing an item.
ItemExpanded( theItem as GraffitiWebTreeItem ) Fires when the user has expanded an item.
ItemIconClicked( theItem as GraffitiWebTreeItem ) Fires when the user has clicked the icon of an item.
ItemSelected( theItem as GraffitiWebTreeItem ) Fires when the user selects an item either with the mouse or keyboard.

Methods

Definition Description
AddItem( theItem as GraffitiWebTreeItem, theParent as GraffitiWebTreeItem = Nil, AddToParentItem as Boolean = True ) Adds an item to the tree. If theParent is Nil, then it is added as a top-level node. AddToParent = True will add it to the Children property of the parent item (mostly for internal use).
CheckItem( theItem as GraffitiWebTreeItem, theValue as Boolean = True ) Sets the item's checkbox value to theValue.
CollapseAll() Collapse all currently expanded items.
CollapseItem( theItem as GraffitiWebTreeItem ) Collapses the supplied item.
DeselectAll() Deselect all items.
DisableItem( theItem as GraffitiWebTreeItem ) Disables an item, making it uncheckable.
EditItem( theItem as GraffitiWebTreeItem ) Makes an item editable.
EditItemEnd( theItem as GraffitiWebTreeItem ) Ends editing of an item.
EnableItem( theItem as GraffitiWebTreeItem ) Enables an item, making it checkable.
ExpandAll() Expands all currently expandable items.
ExpandItem( theItem as GraffitiWebTreeItem ) Expands the supplied item.
FindItem( itemText as String ) as GraffitiWebTreeItem Finds the first item whose Caption matches itemText.
GetDepth( theItem as GraffitiWebTreeItem ) as Integer Returns the level depth of the current item. Top-level items will be 1, their children will be 2, etc.
GetIndexOf( theItem as GraffitiWebTreeItem ) as Integer Gets the index of the supplied item within its parent's Children array, or within the Items array if top-level.
GetIndexPath( theItem as GraffitiWebTreeItem, Separator as String = “/” ) as String Returns an index path to the current item. As an example, calling GetIndexPath( myItem, “/” ) will return something like “3/7/1”.
GetPath( theItem as GraffitiWebTreeItem, Separator as String = “/” ) as String Returns the path to the current item using item captions. As an example, calling GetPath( myItem, “/” ) will return something like “Parent1/Parent2/Parent3/MyItem”.
HasChildren( theItem as GraffitiWebTreeItem ) as Boolean Returns true if the supplied item has children.
InsertItem( theItem as GraffitiWebTreeItem, insertBefore as GraffitiWebTreeItem ) Inserts theItem before insertBefore.
IsChildOf( theItem as GraffitiWebTreeItem, theParent as GraffitiWebTreeItem ) as Boolean Returns true is theItem is a direct child of theParent.
IsFirstChild( theItem as GraffitiWebTreeItem ) as Boolean Returns True if theItem is the first child in its parent.
IsLastChild( theItem as GraffitiWebTreeItem ) as Boolean Returns True if theItem is the last child of its parent.
IsSiblingOf( theItem as GraffitiWebTreeItem, theSibling as GraffitiWebTreeItem ) Returns True if the two supplied items are siblings.
IsTopLevel( theItem as GraffitiWebTreeItem ) as Boolean Returns True if theItem is a top-level item.
RemoveAll() Removes all items from the Tree.
RemoveItem( theItem as GraffitiWebTreeItem, includeChildren as Boolean = True ) Removes theItem from the tree. If includeChildren is False, then children of theItem are added to theItem's parent.
ScrollTo( theItem as GraffitiWebTreeItem ) Scrolls to theItem. If it is hidden under collapsed parents, those parents are expanded automatically.
SelectItem( theItem as GraffitiWebTreeItem ) Selects the specified item.
UpdateCaption( theItem as GraffitiWebTreeItem, newCaption as String ) Updates the specified item with newCaption.
UpdateIcon( theItem as GraffitiWebTreeItem, newIcon as String ) Updates the specified item with newIcon.
UpdateItemStyle( theItem as GraffitiWebTreeItem ) Updates the tree to show theItem.Style.

Properties

Name Type Default Value Description
AllowEdit Boolean False If True, users will be able to edit the contents of individual rows. NOTE: This property should only be set in the IDE's Inspector.
IconCheckbox String “” A FontAwesome icon string to use for an empty checkbox.
IconCheckboxChecked String “fa-checked-square-o” A FontAwesome icon string to use for checked checkboxes.
IconCheckboxUnknown String “fa-square-o” A FontAwesome icon string to use for checkboxes with an unknown value (IE: if some children, but not all, are selected).
IconExpanderClosed String “fa-caret-down” A FontAwesome icon string to use as an expander for items with children.
IconExpanderOpen String “fa-caret-right” A FontAwesome icon string to use as collapser for items with children.
IconStyle WebStyle Nil WebStyle to apply to icons in the tree.
Items() GraffitiWebTreeItem Nil Items in the tree, editing this directly is not recommended.
ItemSelStyle WebStyle Nil WebStyle to apply to selected items.
ItemStyle WebStyle Nil WebStyle to apply to all items.
LockUpdate Boolean False When true, rows added using AddItem will not update style information until LockUpdate is set to False. This should speed up addition of large amounts of rows.
RightToLeft Boolean False When true, the Tree will display in RTL fashion.
SelectedItem GraffitiWebTreeItem Nil The currently selected item.

Examples

Creating an Item with a FontAwesome Icon

GraffitiWebTree provides a constructor for creating items that have a FontAwesome icon to the left of the node's text.

dim firstItemFirstChild as new GraffitiWebTreeItem( "test child", "fas fa-times" )
firstItemFirstChild.Checkbox = True
me.AddItem( firstItemFirstChild, firstItem )

Iterate Items

As GraffitiWebTree items are maintained in a relational manner (using Parents and Children), iterating items can be a tough concept to grasp. The easiest path is to create a method to do your multi-level iteration and perform a specific function. For instance, the following code will loop through all items in the tree and give you an opportunity to do something with the individual item's CheckValue property:

Private Sub StoreCheckValues(ofTree as GraffitiWebTree, inNode as GraffitiWebTreeItem = Nil)
  dim arrCheck() as GraffitiWebTreeItem
  if not IsNull( inNode ) Then
    arrCheck = inNode.Children
  else
    arrCheck = ofTree.Items
  end if
 
  dim intCycle as Integer
  dim intMax as Integer = arrCheck.Ubound
 
  '// Note that you will want to perform the same operation on the parent
  '   before the loop if you're providing inNode and want its value recorded.
 
  dim currentItem as GraffitiWebTreeItem
  for intCycle = 0 to intMax
    currentItem = arrCheck(intCycle)
 
    if currentItem.Checkbox then '// Has a checkbox
      '// Store the value of CheckValue
    end if
 
    '// The following line will iterate over the children of currentItem.
    '   If you only want to do top-level children then you can comment this
    '   or add a method parameter and check it here.
    if currentItem.Children.Ubound >= 0 then StoreCheckValues( ofTree, currentItem )
  next
End Sub

Then you would simply call the method and pass in your tree to iterate through all items:

StoreCheckValues(myTreeInstance)

Or, if you only want to iterate over a specific branch of the tree:

StoreCheckValues(myTreeInstance, myBranchTreeItem)
  • Last modified: 5 weeks ago
  • by agcyphers