Tree API
Introducing
EyzyTree includes a basic API from under the hood. Much can be done with it. But sometimes you need to do something more complicated. In this case, you can use the external API.
A external API has to be included from separately file (module). It is similar to Connection way the Basic API.
Connection
CDN:
As ES6 module:
Using:
Methods
find
findAll
Description: Similar to
find
method. But it returns all found nodes.Arguments:
query
: Query
Returns:
Usage:
remove
Description: Removes matched node.
Arguments:
query
: Querymultiple
: boolean
Returns:
TreeNode
TreeNode[]
null
Usage:
empty
Description: It removes all children nodes. Also it removes
isBatch
property (see Acync)Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
null
Usage:
selected
This method doesn't has a multiple argument. It depends on tree multiple prop.
Description: It the same as Basic:selected(), but it returns a NodeAPI
Returns:
Usage:
select
When using extendSelection argument it will not extend selection for single mode.
In case if you want to to select multiple nodes and extend selection you need to use next hook: Multiple Selection
Description: Selects matched node.
Arguments:
criteria
: Find criteriaextendSelection
: boolean not required. For multiple mode adds the matched node to the list of selected items (it's like a selecting node viaCtrl
)expandOnSelect
boolean, not required.select
method will try to read this property from the tree props if expandOnSelect argument is not pass
Returns:
boolean
null
Usage:
expandOnSelect
example
unselect
Description: Removes Selection for matched node.
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
unselectAll
Description: Removes selection for all selected nodes
checked
Description: For
checkable
mode the library will combine checked nodes into an array. There are different ways to select "checked" nodes by usingvalueConsistsOf
argument.ALL
(default) it will gather all "checked" nodesBRANCH
if node has children and it is checked (and all of the children nodes are checked) then all children nodes will be excluded from the resultLEAF
returns nodes which doesn't has children nodesWITH_INDETERMINATE
the same asALL
plus indeterminate nodes
Arguments:
valueConsistsOf
: 'ALL' | 'BRANCH' | 'LEAF' | 'WITH_INDETERMINATE'showDisabled
: boolean (default false)
Returns:
Usage:
check
Description: Sets matched node as ticked(checked).
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
uncheck
Description: Sets matched node as not ticked(checked).
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
uncheckAll
Description: Uncheck all ticked nodes.
disable
Description: Sets matched node as disabled.
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
enable
Description: Sets matched node as enabled.
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
enableCheckbox
Description: Sets checkbox state for matched node as enabled.
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
disableCheckbox
Description: Sets checkbox state for matched node as disabled.
Arguments:
query
: Querymultiple
: boolean
Returns:
boolean
Usage:
expand
Description: Expands matched node.
Arguments:
query
: Querymultiple
: booleanincludingDisabled
: boolean (default false).
Returns:
boolean
Usage:
collapse
Description: Collapses matched node.
Arguments:
query
: Querymultiple
: booleanincludingDisabled
: boolean (default false).
Returns:
boolean
Usage:
data
You can store here whatever you want.
It is impossible to set/get data for multiple nodes via this method. But it very easy to do it via NodeAPI::data
Description: It is getter/setter for the
data
property of the node.Arguments:
query
: Querykey
: string | objectvalue
: any (not required)
Returns:
undefined
data object
Usage:
This method has different return results
hasClass
Description: Checks if a node has a
className
Arguments:
query
: QueryclassName
: string
Returns:
boolean
Usage:
addClass
Description: It will add classNames for the node. This class will be added to the node with the class
.node-content
(check Node's structure)Arguments:
query
: QueryArray<className>
: string[]multiple
: boolean
Returns:
TreeNode
if node is foundnull
if node is not found
Usage:
removeClass
Description: The same behavior as
addClass
method, but it removes classNamesArguments:
query
: QueryArray<className>
: string[]multiple
: boolean
Returns:
TreeNode
if node is foundnull
if node is not found
Usage:
append
Description: Inserts nodes to the end of the matched node
Arguments:
query
: Querynodes
: string | object | Promiseopts
: Insertion options
Returns:
Promiselike<TreeNode[] | null>
added nodes (always an array)
Usage:
prepend
Description: This method is similar to
append
. But nodes inserting to the beginning of children list. (well ... you know, as well as jQuery :) )Example:
before
Description: This method is similar to
append
. But nodes inserting before matched node.Example:
after
Description: This method is similar to
append
. But nodes inserting after matched node.
Last updated