Class: Items

Items(oTree)

new Items(oTree)

The Items object holds a collection of Item type (item of the control). Use the Items/GetItems() method to access the control's items collection.
Parameters:
Name Type Description
oTree Tree Indicates an object of Tree type that owns the collection

Methods

Add(oItemOptsopt) → {Item}

The Add() method creates and adds a new item into the control. Use the Add() method of the Item object to a new child-item into the control.
Parameters:
Name Type Attributes Description
oItemOpts object <optional>
Specifies the options to create the new item as an object of ItemOptions type
Returns:
Returns the newly created item, as an object of Item type
Type
Item
Example
oTree.Items.Add("caption"), adds a new item, and sets the caption for the first cell.
 oTree.Items.Add({value: "caption"}), adds a new item, and sets the caption for the first cell.
 oTree.Items.Add(["Cell 1","Cell 2"]), adds a new item, and sets the caption for the first and second cell.
 oTree.Items.Add({value: ["Cell 1","Cell 2"]}), adds a new item, and sets the caption for the first and second cell.
 oTree.EnsureVisibleClient(oTree.Items.Add("caption")), adds a new item, sets the caption for the first cell, and scrolls the control to ensure that the newly item fits the control's client area

Clear()

The Clear() method removes all items of the control and inits the control's scroll-bars

GetCount() → {number}

The GetCount() method returns the number of items within the collection
Returns:
Returns the number of items within the collection
Type
number
Example
The following statements are equivalents:

 oTree.Items.GetCount(), counts the items within the control
 oTree.Items.Count, counts the items within the control

where oTree is an object of Tree type

GetLeafCount() → {number}

The GetLeafCount() method counts the leaf-items. A leaf item is an item with no child items.
Returns:
Returns the count of leaf-items.
Type
number
Example
The following statements are equivalents:

 oTree.Items.GetLeafCount(), counts the leaf-items
 oTree.Items.LeafCount, counts the leaf-items

where oTree is an object of Tree type

GetMatchCount() → {number}

The GetMatchCount() method returns the number of items that match the filter
Returns:
Returns the number of items that match the filter as explained below:
  • 0, the control displays/contains no items, and no filter is applied to any column
  • -1, the control displays no items, and there is a filter applied ( no match found )
  • positive number, indicates the number of items within the control (Count property)
  • negative number, the absolute value minus 1, indicates the number of items that matches the current filter ( match found )
Type
number
Example
The following statements are equivalents:

 oTree.Items.GetMatchCount(), counts the items that match the filter
 oTree.Items.MatchCount, counts the items that match the filter

where oTree is an object of Tree type

GetVisibleCount() → {number}

The GetVisibleCount() method returns the number of visible-items
Returns:
Returns the number of visible-items as explained below:
  • 0, the control displays/contains no items, and no filter is applied to any column
  • -1, the control displays no items, and there is a filter applied ( no match found )
  • positive number, indicates the number of visible items, and the control has no filter applied to any column
  • negative number, the absolute value munus 1, indicates the number of visible items, and there is a filter applied ( match found )
Type
number
Example
The following statements are equivalents:

 oTree.Items.GetVisibleCount(), counts the visible items within the control
 oTree.Items.VisibleCount, counts the visible items within the control

where oTree is an object of Tree type

Item(id) → {null|Item}

The Item() method gets the item giving its index, identifier/key or reference. The Item(id) method returns the item based on its index or identifier/key (equivalent of this method)
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the item to request
  • id {string}, specifies a string expression that defines the identifier/key of the item to request
  • id {Item}, specifies the object reference to the item to request for
Returns:
Returns null if the item is not found, or an object of Item type, if the items collection contains the giving id.
Type
null | Item

Remove(id)

The Remove() method removes an item from the collection.
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the item to request
  • id {string}, specifies a string expression that defines the identifier/key of the item to request
  • id {Item}, specifies the object reference to the item to request for

RemoveRange(range) → {number}

The RemoveRange() method removes multiple-items at once
Parameters:
Name Type Description
range any Indicates an item, an array [{Item}], or an exontrol.Arr([{Item}])
Returns:
Returns the number of items being deleted
Type
number