GraffitiTree

View Categories

Enumerations #

This class exposes no enumerations.

Constants #

This class exposes no constants.

Events #

DefinitionParametersReturn TypeDescription
ContextClicktheItem as GraffitiWebTreeItemNoneFires when the user right-clicks an item in the display. mouseX and mouseY are relative to the page, not the control.
mouseX as Integer
mouseY as Integer
ItemCheckedtheItem as GraffitiWebTreeItemFires when the user checks an item in the display. 
ItemClickedtheItem as GraffitiWebTreeItemNoneFires when the user has clicked an item.
ItemCollapsedtheItem as GraffitiWebTreeItemNoneFires when the user has collapsed an expandable item.
ItemContextClickeditem as GraffitiTreeItemRaised when the user right-clicks an item in the tree. 
x as Integer 
y as Integer
ItemDoubleClickedtheItem as GraffitiWebTreeItemNoneFires when the user has double-clicked an item.
ItemEditedtheItem as GraffitiWebTreeItemNoneFires when the user has finished editing an item.
ItemExpandedtheItem as GraffitiWebTreeItemNoneFires when the user has expanded an item.
ItemIconClickedtheItem as GraffitiWebTreeItemNoneFires when the user has clicked the icon of an item.
ItemSelectedtheItem as GraffitiWebTreeItemNoneFires when the user selects an item either with the mouse or keyboard.

Methods #

DefinitionParametersReturn TypeDescription
AddItemtheItem as GraffitiWebTreeItemNoneAdds 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).
theParent as GraffitiWebTreeItem = Nil
AddToParentItem as Boolean = True
CheckedItemsNoneGraffitiTreeItem()Returns all items at any depth whose Checked property is equal to True.
CheckItemtheItem as GraffitiWebTreeItemNoneSets the item’s checkbox value to theValue.
theValue as Boolean = True
CollapseAllNoneNoneCollapse all currently expanded items.
CollapseItemtheItem as GraffitiWebTreeItemNoneCollapses the supplied item.
DeselectAllNoneNoneDeselect all items.
DisableItemtheItem as GraffitiWebTreeItemNoneDisables an item, making it uncheckable.
EditItemtheItem as GraffitiWebTreeItemNoneMakes an item editable.
EditItemEndtheItem as GraffitiWebTreeItemEnds editing of an item. 
EnableItemtheItem as GraffitiWebTreeItemNoneEnables an item, making it checkable.
ExpandAllNoneNoneExpands all currently expandable items.
ExpandItemNonetheItem as GraffitiWebTreeItemExpands the supplied item.
FindItemitemText as StringGraffitiWebTreeItemFinds the first item whose Caption matches itemText.
FindByUUIDuuid as StringGraffWebTreeItemFind the first item whose UUID matches uuid.
inItems() as GraffWebTreeItem
GetDepththeItem as GraffitiWebTreeItemIntegerReturns the level depth of the current item. Top-level items will be 1, their children will be 2, etc.
GetIndexOftheItem as GraffitiWebTreeItemIntegerGets the index of the supplied item within its parent’s Children array, or within the Items array if top-level.
GetIndexPaththeItem as GraffitiWebTreeItemStringReturns an index path to the current item. As an example, calling GetIndexPath( myItem, “/” ) will return something like “3/7/1”.
Separator as String = “/”
GetPaththeItem as GraffitiWebTreeItemStringReturns the path to the current item using item captions. As an example, calling GetPath( myItem, “/” ) will return something like “Parent1/Parent2/Parent3/MyItem”.
Separator as String = “/”
HasChildrentheItem as GraffitiWebTreeItemBooleanReturns true if the supplied item has children.
InsertItemtheItem as GraffitiWebTreeItemNoneInserts theItem before insertBefore.
insertBefore as GraffitiWebTreeItem
IsChildOftheItem as GraffitiWebTreeItemBooleanReturns true is theItem is a direct child of theParent.
theParent as GraffitiWebTreeItem
IsFirstChildtheItem as GraffitiWebTreeItemBooleanReturns True if theItem is the first child in its parent.
IsLastChildtheItem as GraffitiWebTreeItemBooleanReturns True if theItem is the last child of its parent.
IsSiblingOftheItem as GraffitiWebTreeItemBooleanReturns True if the two supplied items are siblings.
theSibling as GraffitiWebTreeItem
IsTopLeveltheItem as GraffitiWebTreeItemBooleanReturns True if theItem is a top-level item.
RemoveAllNoneNoneRemoves all items from the Tree.
RemoveItemtheItem as GraffitiWebTreeItemNoneRemoves theItem from the tree. If includeChildren is False, then children of theItem are added to theItem’s parent.
includeChildren as Boolean = True
ScrollTotheItem as GraffitiWebTreeItemNoneScrolls to theItem. If it is hidden under collapsed parents, those parents are expanded automatically.
SelectItemtheItem as GraffitiWebTreeItemNoneSelects the specified item.
UpdateCaptiontheItem as GraffitiWebTreeItemNoneUpdates the specified item with newCaption.
newCaption as String
UpdateIcontheItem as GraffitiWebTreeItemNoneUpdates the specified item with newIcon.
newIcon as String
UpdateItemStyletheItem as GraffitiWebTreeItemNoneUpdates the tree to show theItem.Style.

Properties #

NameTypeDefault ValueDescription
AllowEditBooleanFalseIf True, users will be able to edit the contents of individual rows. NOTE: This property should only be set in the IDE’s Inspector.
CustomIconsBooleanFalseIf True, icon properties will be used to override defaults.
IconCheckboxString“”A FontAwesome icon string to use for an empty checkbox.
IconCheckboxCheckedString“fa-checked-square-o”A FontAwesome icon string to use for checked checkboxes.
IconCheckboxUnknownString“fa-square-o”A FontAwesome icon string to use for checkboxes with an unknown value (IE: if some children, but not all, are selected).
IconExpanderClosedString“fa-caret-down”A FontAwesome icon string to use as an expander for items with children.
IconExpanderOpenString“fa-caret-right”A FontAwesome icon string to use as collapser for items with children.
IconExpanderStyleGraffitiStyleNilGraffitiStyle applied to item expanders.
IconStyleWebStyleNilWebStyle to apply to icons in the tree.
Items()GraffitiWebTreeItemNilItems in the tree, editing this directly is not recommended.
ItemSelStyleGraffitiStyleNilWebStyle to apply to selected items.
ItemStyleGraffitiStyleNilWebStyle to apply to all items.
LockUpdateBooleanFalseWhen 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.
RightToLeftBooleanFalseWhen true, the Tree will display in RTL fashion.
SelectedItemGraffitiWebTreeItemNilThe 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)