TreeCollection overview
A set of API methods and events that allow you to work with data of a component with tree-like structure. Applicable to Menu, Ribbon, Sidebar, Toolbar, Tree, Grid in the TreeGrid mode.
Methods
Name | Description |
---|---|
add() | adds an item to a component |
canCopy() | checks whether it is possible to copy a control into some other control |
copy() | adds a copy of an item and places it in the specified position |
eachChild() | iterates through child items of a control |
eachParent() | iterates through all the parent items (the immediate parent and its parent, etc until the parent is the component itself) |
exists() | checks whether the specified item exists in the component |
filter() | filters controls by some criteria |
forEach() | iterates over all items of a tree collection |
getFilters() | returns an object with the applied filters |
getId() | gets the ID of an item |
getIndex() | gets the current position of an item |
getItem() | gets an item by its ID |
getItems() | gets the child items of a control |
getLength() | counts child items of a control |
getParent() | gets the ID of the parent of the control |
getRoot() | returns the ID of the master component |
haveItems() | checks whether an item has children |
isSaved() | checks whether the changes made in a tree collection are saved |
load() | loads items from a file |
loadItems() | loads child items of a control from a file |
move() | moves items to different positions |
parse() | loads a collection of items from a local source |
refreshItems() | refreshes child items of a control |
remove() | removes an item |
removeAll() | clears the component of all controls |
resetFilter() | resets the active filters |
restoreOrder() | restores the component to the state previous to sorting / filtering |
save() | saves changes made in a tree collection to the server side |
serialize() | serializes the component data into JSON, XML or CSV format |
sort() | sorts controls according to some criteria |
update() | changes an item |
Events
Name | Description |
---|---|
afterAdd | fires after adding a new item into a tree collection |
afterItemLoad | fires after loading an item |
afterRemove | fires after removing a new item from a tree collection |
beforeAdd | fires before adding a new item into a tree collection |
beforeItemLoad | fires before loading an item |
beforeRemove | fires before removing an item from a tree collection |
change | fires when a tree collection is modified |
filter | fires after filtering a tree collection |
load | fires when items are loaded in a tree collection |
loadError | fires when loading of data fails |
removeAll | fires when all items are removed from a tree collection |
Ways of applying events
To call the event of TreeCollection, you may use either of the two syntaxes:
- common syntax (via the
data
object of the component)
menu.data.events.on("afterAdd", function(newItem){
console.log("A new item is added");
});
- or short syntax (right through the component)
menu.events.on("afterAdd", function(newItem){
console.log("A new item is added");
});