Class: Item

Item

new Item(data) → {Object}

Builds an _item that uses item related api calls, what we mean when we say "constructed by _item"
Parameters:
Name Type Description
data Object Raw data to be converted into an item
Source:
Returns:
this Returns itself with the new properties.
Type
Object

Methods

add(component, toTopopt) → {Object}

Add a child item into the item and correctly assign depth and other properties
Parameters:
Name Type Attributes Description
component Object Item created with cosntructor _item, missing depth information
toTop Boolean <optional>
Whether the item should be added to the top or bottom of children array
Source:
Returns:
this The current item.
Type
Object

child(childID) → {Object}

Returns single child based on id
Parameters:
Name Type Description
childID Number Id of the child inside this item
Source:
Returns:
child The child object constructed by _item
Type
Object

isAncestor(item) → {Boolean}

Checks if item is ancestor (contains) of another item passed as argument
Parameters:
Name Type Description
item Object An item constructed by _item
Source:
Returns:
result Whether the item is ancestor of item passed as argument
Type
Boolean

isDescendant(item) → {Boolean}

Checks if item is descendant (a child) of another item passed as argument
Parameters:
Name Type Description
item Object An item constructed by _item
Source:
Returns:
result Whether the item is descendant of item passed as argument
Type
Boolean

move(toID) → {Object}

Move item from one place to another within the tree
Parameters:
Name Type Description
toID Number Unique id of the container item to move to
Source:
Returns:
this The current item.
Type
Object

next() → {Object}

Returns next sibling based on position in the parent list
Source:
Returns:
next The next object constructed by _item
Type
Object

parent() → {Object}

Returns parent of the item one level above
Source:
Returns:
parent The parent object constructed by _item
Type
Object

prev() → {Object}

Returns previous sibling based on position in the parent list
Source:
Returns:
prev The previous object constructed by _item
Type
Object

redoDepth()

Reassigns depth information when tree manipulations happen so depth remains accurate within object descendants
Source:

removeChild(childID) → {Object}

Deletes child from item by unique id
Parameters:
Name Type Description
childID Number Id of the child inside this item
Source:
Returns:
this The item containing the child
Type
Object

removeSelf(childID) → {Object}

Deletes itself
Parameters:
Name Type Description
childID Number Id of the child inside this item
Source:
Returns:
parent The parent of the removed item
Type
Object

sortChildren(treebeard, direction, sortType, index)

Sorts children of the item by direction and selected field.
Parameters:
Name Type Description
treebeard Object The instance of the treebeard controller being used
direction String Sort direction, can be 'asc' or 'desc'
sortType String Whether the sort type is number or alphanumeric
index Number The index of the column, needed to find out which field to be sorted
Source: