RMP_Tree

Tree widget

new RMP_Tree()

Example
   var data = [
   			{"value":"RunMyProcess","href":"http://www.runmyprocess.com/","editable":"false","type":"text",
   				"children":[
   							{"value":"1338315899","type":"date"},
   							{"value":"109.23333","type":"number"}
   						]},
   			{"value":"lazy node","lazy":"true",
   			"dataUrl":"https://live.runmyprocess.com/live/1/object/tree/?P_query={}&P_mode=TEST&P_nb=100&P_first=0&P_detail=false&asynchronous=true"},
   
   			{"value":"1338315800","type":"date"},
   			{"value":"259.3526","type":"number","icon":"http://localhost/rmp/script/com.runmyprocess.ApplicationRunner/images/add.png"}];
   
   id_tree.setData(data);
   
   id_tree.setLoadSuccessHandler(function(node,data){
      // the fetched data is a valid json node list; let's append it directly in node
   	id_tree.setNodeChildrenDataString(node.id,data);
   });
 

Methods

clear()

Clears all tree items from the current tree.

getChildrenAttribute() → {String}

Gets the attribute used to parse child nodes
Returns:
the attribute used to parse child nodes
Type
String

getCollapseHandler() → {RMP_Tree~nodeHandler}

The function used to handle node collapsed event
Returns:
handler
Type
RMP_Tree~nodeHandler

getContainerIndex() → {String}

Returns:
the index of the container of the widget, it might be the index of the column if the widget is in an array or the index of the tab if it's in a tab panel
Type
String

getData() → {Array.<RMP_Tree~RMP_TreeItem>}

Returns tree data
Returns:
nodes list of RMP_Tree~RMP_TreeItem
Type
Array.<RMP_Tree~RMP_TreeItem>

getDataString() → {String}

Returns tree data as a json string
Returns:
nodes list String
Type
String

getDatePattern()

Gets the pattern used to format nodes of type date
Returns:
the pattern used to format date nodes

getElement() → {object}

This function returns the html object of the widget
Returns:
Type
object

getExpandHandler() → {RMP_Tree~nodeHandler}

The function used to handle node expanded event
Returns:
handler
Type
RMP_Tree~nodeHandler

getLoadFailuresHandler() → {RMP_Tree~loadFailureHandler}

The function used when failed to load lazy node data
Returns:
handler function
Type
RMP_Tree~loadFailureHandler

getLoadSuccessHandler() → {RMP_Tree~loadSuccessHandler}

The function used when lazy node data is loaded successfully
Returns:
handler function
Type
RMP_Tree~loadSuccessHandler

getName() → {String}

This function returns the id as string of the widget
Returns:
Type
String

getNodeData(nodeId) → {RMP_Tree~RMP_TreeItem}

Returns node data
Parameters:
Name Type Description
nodeId String the id of the node
Returns:
node data
Type
RMP_Tree~RMP_TreeItem

getNodeDataString(nodeId) → {String}

Returns node data as a json string
Parameters:
Name Type Description
nodeId String the id of the node
Returns:
node data as a json string
Type
String

getNumberPattern()

Gets the pattern used to format nodes of type number
Returns:
the pattern used to format number nodes

getParent() → {object}

Returns:
the parent widget of a widget
Type
object

getSelectedData()

Gets a list of selected nodes RMP_Tree~RMP_TreeItem
Returns:
object

getSelectionHandler() → {RMP_Tree~nodesHandler}

Get the function used when a tree item is selected
Returns:
handler function
Type
RMP_Tree~nodesHandler

getTooltip() → {String}

This function returns the tooltip text of the widget
Returns:
Type
String

getType() → {String}

This function returns the type of the widget(RMP_Image, RMP_Html, RMP_Scripter, RMP_StaticTextwidget, RMP_Button, RMP_TextInput, RMP_ListBox, RMP_MultiSelectionCheckBox, RMP_RadioButton, RMP_Array, RMP_FileUpload... )
Returns:
Type
String

getValueAttribute() → {String}

Gets the attribute used for the displayed values
Returns:
the attribute used for the displayed value
Type
String

insertAbove(widget)

This function allows you to insert above widgetID, the new widget created thanks to new RMP_xxx() function
Parameters:
Name Type Description
widget object the inserted widget

insertAfter(widget)

This function allows you to insert on the left of widgetID, the new widget created thanks to new RMP_xxx() function
Parameters:
Name Type Description
widget object the inserted widget

insertBefore(widget)

This function allows you to insert on the right of widgetID, the new widget created thanks to new RMP_xxx() function
Parameters:
Name Type Description
widget object the inserted widget

insertBelow(widget)

This function allows you to insert below widgetID, the new widget created thanks to new RMP_xxx() function
Parameters:
Name Type Description
widget object the inserted widget

isActive() → {boolean}

This function returns true if the widget is active and false otherwise
Returns:
Type
boolean

isEnabled() → {boolean}

This function returns true if a widget is active and false otherwise
Returns:
Type
boolean

isIndexed() → {boolean}

This function returns true if the the widget's variable is an array and false otherwise
Returns:
Type
boolean

isVisible() → {boolean}

This function returns true if the widget is visible and false otherwise
Returns:
Type
boolean

moveAfter(widget)

This function allows you to move widgetID2 after (on the the right) widgetID1
Parameters:
Name Type Description
widget object the inserted widget

moveBefore(widget)

This function allows you to move widgetID2 before (on the left) widgetID1
Parameters:
Name Type Description
widget object the inserted widget

remove(widget)

This function allows you to remove widgetID. If removeVariable is set to true, it will also deleted content of variable attached to widget
Parameters:
Name Type Description
widget object the inserted widget

setActive(active)

This function allows to set the widget as active/inactive
Parameters:
Name Type Description
active boolean

setChildrenAttribute(attribute)

Sets the attribute used to parse child nodes
Parameters:
Name Type Description
attribute String
Example
   var data = [{"value":"Node 1", "custom_children_attribute":[{"value":"1338315899","type":"date"}}]},
   			{"value":"1338315800","type":"date"}];
   
   id_tree.setChildrenAttribute("custom_children_attribute");
   
   id_tree.setData(data);
 

setCollapseHandler(handler)

Adds nodes collapse handler
Parameters:
Name Type Description
handler RMP_Tree~nodeHandler callback to be used when a node is collapsed, the callback function should take a node parameter
Example
   idTree.setCollapseHandler( function(node){ alert(node.id+" collapsed!"); } );
 

setData(object)

Fill the tree with a list of nodes
Parameters:
Name Type Description
object Array.<RMP_Tree~RMP_TreeItem> nodes list of RMP_Tree~RMP_TreeItem
Example
   var data = [
   			{"value":"RunMyProcess","href":"http://www.runmyprocess.com/","editable":"false","type":"text",
   				"children":[
   							{"value":"1338315899","type":"date"},
   							{"value":"109.23333","type":"number"}
   						]},
   			{"value":"lazy node","lazy":"true",
   			"dataUrl":"https://live.runmyprocess.com/live/1/object/tree/?P_query={}&P_mode=TEST&P_nb=100&P_first=0&P_detail=false&asynchronous=true"},
   
   			{"value":"1338315800","type":"date"},
   			{"value":"259.3526","type":"number","icon":"http://localhost/rmp/script/com.runmyprocess.ApplicationRunner/images/add.png"}];
   
   id_tree.setData(data);
 

setDataString(jsonString)

Fill the tree with a json string
Parameters:
Name Type Description
jsonString String nodes list as a json string
Example
   var dataString = "{\"value\":\"1338315800\",\"type\":\"date\"},{\"value\":\"259.3526\",\"type\":\"number\"}]";
   id_tree.setDataString(dataString);
 

setDatePattern(pattern)

Set a pattern to format nodes of type date
Parameters:
Name Type Description
pattern String
Example
   id_tree.setDatePattern("MM-dd-yyyy");
 

setEnabled(e)

This function allows to set a widget as active/inactive
Parameters:
Name Type Description
e boolean

setExpandHandler(handler)

Adds nodes expand handler
Parameters:
Name Type Description
handler RMP_Tree~nodeHandler callback to be used when a node is expanded.
Example
   idTree.setExpandHandler( function(node){ alert(node.value+" : "+node.type+" : "node.editable); } );
 

setLoadFailureHandler(handler)

Adds a callback used when failed to load data after expanding a lazy node. NOTE: this callback is used for all tree nodes
Parameters:
Name Type Description
handler RMP_Tree~loadFailureHandler failure callback function
Example
   idTree.setLoadFailureHandler(function(node,error){
   	alert("failed to load "+node.id+". error detail: "+error);
   });
 

setLoadSuccessHandler(handler)

Adds a callback used when data is retrieved successfully from after expanding a lazy node. NOTE: this callback is used for all tree nodes
Parameters:
Name Type Description
handler RMP_Tree~loadSuccessHandler success callback function
Example
   // example one
   idTree.setLoadSuccessHandler(function(node,data){
      // the fetched data is a valid json node list; let's append it directly in node
   	idTree.setNodeChildrenDataString(node.id,data);
   });
   
   // example two
   idTree.setLoadSuccessHandler(function(node,data){
   	// data in this case is an xml feed; let's build our node list by calling another function that knows data feed structure
      // before appending resulted list node in node
   	var childrenArray = buildChildren(data);
   	idTree.setNodeChildrenData(node.id,childrenArray);
   });
 

setNodeChildrenData(nodeId, object)

Set or update a tree node's children
Parameters:
Name Type Description
nodeId String the id of the node to update
object object node children list of RMP_Tree~RMP_TreeItem
Example
   var nodeChildrenData = [{"value":"1338315899","type":"date"},{"value":"109.23333","type":"number"}];
   id_tree.setNodeChildrenData("id_node",nodeChildrenData);
 

setNodeChildrenDataString(nodeId, jsonString)

Set or update a tree node's children
Parameters:
Name Type Description
nodeId String the id of the node to update
jsonString String node children list as json string
Example
   var nodeChildrenDataString = "[{\"value\":\"1338315899\",\"type\":\"date\"},{\"value\":\"109.23333\",\"type\":\"number\"}]";
   id_tree.setNodeChildrenDataString("id_node",nodeChildrenDataString);
 

setNodeData(nodeId, object)

Set or update a tree node
Parameters:
Name Type Description
nodeId String the id of the node to update
object RMP_Tree~RMP_TreeItem node data
Example
   var nodeData = {"value":"RunMyProcess","href":"http://www.runmyprocess.com/","editable":"false","type":"text",
   				"children":[
   							{"value":"1338315899","type":"date"},
   							{"value":"109.23333","type":"number"}
   						]};
   id_tree.setNodeData("id_node",nodeData);
 

setNodeDataString(nodeId, jsonString)

Set or update a tree node
Parameters:
Name Type Description
nodeId String the id of the node to update
jsonString String node data as json string
Example
   var nodeDataString = "{\"value\":\"1338315800\",\"type\":\"date\",\"editable\":\"false\"}";
   id_tree.setNodeDataString("id_node",nodeDataString);
 

setNumberPattern(pattern)

Set a pattern to format nodes of type number
Parameters:
Name Type Description
pattern String
Example
   id_tree.setNumberPattern("#,##");
 

setSelectionHandler(handler)

Adds nodes selection handler
Parameters:
Name Type Description
handler RMP_Tree~nodesHandler a function used when a node is selected, this function should take an array parameter that contains selected nodes
Example
   idTree.setSelectionHandler( function( selectedItems ){ alert("selected Items count: "+selectedItems.length); } );
 

setTooltip(tooltip)

This function sets the tooltip text of the widget
Parameters:
Name Type Description
tooltip String

setValueAttribute(attribute)

Sets the attribute used for the displayed values
Parameters:
Name Type Description
attribute String
Example
   var data = [{"custom_value_attr":"Node 1"},{"custom_value_attr":"1338315800","type":"date"}];
   
   id_tree.setValueAttribute("custom_value_attr");
   
   id_tree.setData(data);
 

setVisible(v)

This function allows to set the widget as visible/invisible
Parameters:
Name Type Description
v boolean

unselect()

Unselect all selected values

Type Definitions

loadFailureHandler(node, error)

Parameters:
Name Type Description
node RMP_Tree~RMP_TreeItem
error Object

loadSuccessHandler(node, data)

Parameters:
Name Type Description
node RMP_Tree~RMP_TreeItem
data Object

nodeHandler(node)

Parameters:
Name Type Description
node RMP_Tree~RMP_TreeItem

nodesHandler(nodes)

Parameters:
Name Type Description
nodes Array.<RMP_Tree~RMP_TreeItem> list of nodes of RMP_Tree~RMP_TreeItem

RMP_TreeItem

Tree item
Properties:
Name Type Argument Description
value String <optional>
value of the node. Html is not allowed here.
label String <optional>
Displayed name of the node.
id String <optional>
Id of the node, only needed if you want to use a given node with some JS functions setNodeData, getNodeData, ...
type String <optional>
Type of the node value. A node can be a number, a date, a list, a boolean or a text. by default it is text.
link String <optional>
A facultative url if you want to add a link on the displayed value.
lazy String <optional>
Loading child nodes on demand, false by default. When a node is lazy loaded, you SHOULD configure dataUrl attribute and a loadSuccessHandler to handle the fetched data before appending it back to the node.
dataUrl String <optional>
The url that provides the data that well be fetched to build the lazy loaded node. Cross-site requests are not allowed here the fetched data should be hosted in RunMyProcess servers!
icon String <optional>
Image url used to customize the node icon. By default a folder icon is used for nodes, and a page icon for leafs.
editable String <optional>
The node value is editable or not. True by default.
children String <optional>
Array of child nodes of type RMP_Tree~RMP_TreeItem.