Constructors
Name | Type | Description |
---|---|---|
id |
string |
Unique id of the item in the tree |
name |
string |
Name of this node |
Example
// rootnode of the tree
var rootItem = new otris.TreeItem(4711, "RootNodeLabel");
// first entry
var subItem = new otris.TreeItem(0815, "SubNodeLabel");
//action will be fired if the node is clicked
subItem.action = "showFile:" + docFile.getAutoText("%id%");
subItem.isActive = true; // directly selected
//add node to the rootnode
rootItem.addItem(subItem);
//call the transfer function to get the scripttree XML
return rootItem.transfer();
Members
-
action
-
Action which will be fired when the node is clicked.
Possible actionsshowFile:[FILE_ID]
,showFolder:[FOLDER_ID]
andexecuteScript:[SCRIPTNAME]
Example
rootItem.action = "showFile:" + myFileId;
-
activebullet
-
Adds an icon to the tree item. Possible values: image path, entypo icon or ionicons icon
Example
item.activebullet = "entypo:help;";
-
bullet
-
DEPRECATED! Do not use this attribute!
-
docItemsDropAction
-
Drop action which will be fired when something will be dropped to this node.
The script is only executed if items from within documents are dropped on the node
The script is called with the following json encoded parameter object (parameter name:dndActionJSON
):dndAction = { treeType string "scriptTree" nodeId string id of the drop target action string "copy"/"move" itemIds array ids of the dropped items itemType string type of the items }
Decode the parameter object in the script:var dndAction = JSON.parse(dndActionJSON);
Example
item.docItemsDropAction = "executeScript:myScript";
-
draggable
-
Specifies if the tree item is draggable (defaults to
true
)Example
treeItem.draggable = false;
-
dropaction
-
Drop action which will be fired when something will be dropped to this node.
The defined script is executed before a file is uploaded. The script should return
a fileId of a document. script returnType = (showFile|showNewFile)Example
item.dropaction = "executeScript:myScript&myParam=1234";
-
hasChilds
-
Specifies if the tree item has childs (relevant for lazy loading, defaults to
false
)- Since:
- Documents 5.0d HF2
Example
treeItem.hasChilds = true;
-
id
-
Unique id of the node in the tree
-
isActive
-
Selection of this node true or false
-
items
-
List of nodes
-
lazyLoad
-
If set to
true
the children of the nodes are lazy loaded (Only relevant for the root node, defaults tofalse
)
Note: Lazy loading is only used if the node data does not containchildren
(added withaddItem
) and thehasChilds
flag is set totrue
.
In the example below you can see how to return a subtree usingotris.tree.getScriptTreeEvent()
.- Since:
- Documents 5.0d HF2
Example
rootItem.lazyLoad = true; var nodeId, subTreeRoot, index, newNode, treeEvent = otris.tree.getScriptTreeEvent(); if(treeEvent && treeEvent.name === "subtree" && treeEvent.nodeId) { nodeId = treeEvent.nodeId; subTreeRoot = new otris.TreeItem(nodeId, nodeId); for (index = 0; index < 5; index++) { newNode = new otris.TreeItem(nodeId + "_" + index, nodeId + "_" + index); newNode.activebullet = "entypo:leaf"; subTreeRoot.addItem(newNode); } return subTreeRoot.transfer(); }
-
name
-
Name of the tree node
-
openTreeLevel
-
Sets the opened tree level.
-
parent
-
Parent of this child, or null if it is the root node
-
tooltip
-
Tooltip for the tree node
- Since:
- Documents 5.0c
-
treeItemsDropAction
-
The tree item drop action will be fired when one or more tree items are dropped on a tree node.
The script is called with the following json encoded parameter object (parameter name:dndActionJSON
):
This property is only relevant for the root nodedndAction = { nodeId string id of the drop target itemIds array ids of the dropped nodes action string "copy"/"move" }
Decode the parameter object in the script:var dndAction = JSON.parse(dndActionJSON);
Example
item.treeItemsDropAction = "executeScript:treeItemsDropScript";
-
updateOutbarLabel
-
If set to true the outbar label is updated with the defined tree title (Only relevant for the root node)
Example
rootItem.updateOutbarLabel = false;
-
url
-
URL which will be opend if the node is clicked
Methods
-
addItem()
-
Add a new node as a childnode to this node.
This node will be the parent of the added node.Example
var rootItem = new treeItem(4711, "RootNodeLabel"); var subItem = new treeItem(0815, "SubNodeLabel"); rootItem.addItem(subItem);
-
convertToXMLString(value){string}
-
Converts the string to a valid XML string. For internal purposes only.
Name Type Description value
string value to convert
Returns:
Type Description string the converted string -
getAll(myLevel){string}
-
Internal function for building the ScriptTree XML.
Name Type Description myLevel
number Current level in the tree
Returns:
Type Description string XML document representing the tree -
getAsXML(){string}
-
Internal function returning the attributes of this class as ScriptTree XML.
Returns:
Type Description string XML fragment with the attributes of this class -
setAcceptedTypes(types)
-
Sets the accepted types (e.g. for drag and drop) for this tree item (defaults to:
["node"]
)
SeesetType
for valid type stringsName Type Description types
Array.<string> An array of accepted types
-
setOpenTreeLevel(level)
-
Set the level up to which the tree will be opened.
Name Type Description level
Number Level up wich the tree will be opened
-
setType(type)
-
Sets the type for this tree item (defaults to:
node
)
Only accepts the following characters for the given string:a-z
,0-9
,-
and_
Non valid strings are automatically transformed (characters are transformed to lower case or replaced with_
)Name Type Description type
string The type for this tree item
-
transfer()
-
Make this object ready for being transferred to the client.