PropertyEventMethodIndex
WebSquare.uiplugin.treeview - 5.0_1.3015A.20180410.143527

Creates a tree view layout for the structured data.
The developer can add checkboxes and images (icons) in each node, and can exchange data (node) between the TreeView components through mouse dragging.
At the highest level is the div tag, and the lower levels are various types of tags.

Type

uiplugin

Property Summary

accessibility
[true,false] Enables the web accessibility mode. true is not to draw node lines but to add HTML properties such as aria-expanded.
alwaysDraw
[default:false, true] In case of true, draws all child items. In case of false, draws only the items lower than the showTreeDepth.
checkAllChildNodes
[default:false, true] Automatically selects all child nodes upon selection of the parent node.
checkboxDisabledFalseValue
false value of the disabled property of the checkbox. Valid when the ref of the checkbox and the ref of the checkboxDisabled ref are defined.
checkboxDisabledTrueValue
true value of the disabled property of the checkbox. Valid when the ref of the checkbox and the ref of the checkboxDisabled ref are defined.
class
Same as the class property in HTML standard. One or more classes defined in the CSS file or in the style block can be applied (through the use of the space as the separator).
dataType
[default:recursive, listed] Type of the data format (tree or list).
defaultImage
Path of the default icon image on the node.
disabled
Disabled status
dynamicAppend
[true,false] Dynamically appends a tree.
escape
[true, false] Converts <>&" characters into HTML Escape characters.
expandedImage
Image to be displayed upon expanding
falseValue
false value of the checkbox
hierarchy
[default:false, true] Checks the parent node when the child node is selected.
id
ID of the component. Allocated as a global object. Scripts access the component through the ID.
labelclass
Class to apply to the label of each node in the tree
lineShow
[default:true, false] Shows line between the nodes in the tree.
refreshCheckboxDisableModel
[default:false, true] Refreshes the model (DataCollection or InstanceData) upon a change in the disabled status of the checkbox.
refreshCheckboxModel
[default:false, true] Refreshes the model (DataCollection or InstanceData) upon a change in the checkbox value.
scrollFix
[default:false, true] Fixes the scroll by preventing focusing upon node clicking. true is to fix, and false is to allow focusing and scrolling.
showCheckbox
[default:false, true] Shows the checkbox next to the node.
showTreeDepth
Initial depth to be displayed upon display of the tree
title
Same as the title property of HTML. Displays the Text upon the end user's hovering the mouse over the browser.
toggleButtonEvent
[default:onclick, onmousedown] Specifies the toggling moment - upon clicking of the toggling button or upon mouse clicking.
toggleEvent
[default:ondblclick, onclick, none] Event to close or open the node list.
toolTip
Tooltip provided by WebSquare5. Displays additional information of the component.
tooltipClass
CSS class to apply to the tooltip when the tooltipDisplay is true.
tooltipDisplay
[default:false, true] Displays the tooltip when the node label is fully displayed.
tooltipGroupClass
[default:true, false] Includes w2group style in the tooltip.
tooltipTime
Time to be taken to display the tooltip (in seconds) when the tooltipDisplay is true.
trueValue
true value of the checkbox
useDrag
[default:false, true] Uses dragging.
useHirarchySelect
[default:false, true] Selects the parent node when a child node is selected.
userData1
User-defined property
userData2
User-defined property
userData3
User-defined property

Event Summary

onchange
Triggered upon selection of a different node.
oncheckboxclick
Triggered upon clicking of the checkbox.
onclick
Triggered upon clicking of label, checkbox, icon, or toggling button on the tree.
ondblclick
Triggered upon double-clicking of the label on the tree.
ondragleave
Triggered upon the dragging mouse pointer moving out of the pure label area (not including the icon area) of the treeview node. Valid when the useDrag is true.
ondragover
Triggered when the dragging mouse pointer is over a certain node in the treeview. Valid only when the useDrag is true.
ondrop
Triggered upon dragging and dropping a certain node in the treeview to another node. Valid when the useDrag is true.
onimageclick
Triggered upon clicking of the node icon.
onlabelclick
Triggered upon clicking of the label.
onrightbuttonclick
Triggered upon right-clicking the label of the treeview node.
ontoggleclick
Triggered upon the end user's clicking of the toggling image (icon).
onviewchange
Triggered upon selection of label, checkbox, icon, or toggling button on the treeview through the keyboard. Not triggered if the value was changed by a script.

Method Summary

addClass( className )
Adds a class to the component.
appendData( index , xmlArray )
Adds user data under the node of the corresponding index.
appendNode( parentNode , childNode )
Appends childNode under the parentNode.
appendXmlNodes( parentNode , xmlArray )
Adds a node under the specified parent node based on the XML data.
bind( eventType , function )
Dynamically allocates events to the component.
changeClass( oldClassName , newClassName )
Renames the class from oldClassName to newClassName.
checkByIndex( value , checkValue , childCheck )
Finds the node of the corresponding index and sets the value of the checkbox.
checkByValue( value , checkValue , childCheck )
Adds a node under the specified parent node based on the XML data.
collapseNode( value , hierarchy )
Folds the node of the corresponding value or index. The index starts from 1.
disableCheckboxByValue( value , checkDisabled , childDisalbed )
Disables or enables the checkbox in the node of the corresponding value according to the checkDisabled setting.
expandNode( value , hierarchy )
Expands the node of the corresponding value or index which starts from 1.
findNodeByIndex( index , select )
Finds the node of the corresponding index. When the second parameter is true, selects the corresponding node.
findNodeByValue( value , select )
Finds the node of the corresponding value. When the second parameter is true, selects the corresponding node.
focus( )
Moves the focus to the component.
getCheckedIndexes( options )
Returns the indices of the checkbox-selected nodes as an array.
getCheckedLabels( options )
Returns the labels of the checkbox-selected nodes as an array.
getCheckedNodes( options )
Returns an array of the nodes with the checkbox selected.
getCheckedValues( options )
Returns the values of the checkbox-selected nodes as an array.
getChildData( value , hierarchy )
Returns the child data of the node of the corresponding value (in the model).
getDataListInfo( )
Returns the list of the DataList bound with the treeview.
getDisabled( )
Gets the current value of the disabled property.
getGenerator( )
Called by a component under the Generator component. When called, gets the parent Generator object.
getID( )
Gets the ID of the component.
getLastChildIndex( srcIndex )
Returns the index of the last child node under the node of srcIndex. (Child nodes of all depths will be searched.)
getOpacity( )
Gets the opacity of the component defined in CSS.
getParentValue( value )
Finds the parent node based on the node value, and returns the node.
getPluginName( )
Gets the pluginName (or the name) of the component.
getPosition( positionName )
Gets the left or top position of the component.
getReadOnly( )
Gets the current setting of the readOnly property.
getSelectedIndex( )
Returns the index of the selected node.
getSelectedLabel( )
Returns the label of the component of the selected node.
getSelectedNode( )
Returns the selected node object.
getSelectedValue( )
Returns the value of the selected node.
getSize( sizeName )
Gets the size of the component.
getStyle( propertyName )
Gets the current value of the propertyName of the component defined in CSS.
getStyleValue( style )
[deprecated] Use getStyle instead.
getTitle( )
Gets the title value.
getUserData( key )
Returns the user-defined property value set by setUserData as the user data or source (page XML).
getXPathByValue( value )
Returns the XPAth of the node of the corresponding value.
hasClass( className )
Checks whether the component has className received as a parameter or not.
hide( )
Hides the component.
isLeaf( )
Returns whether the selected node is a leaf (wihtout a child node.)
isOpen( index )
Checks the opening status of the node based on the node index.
moveNode( srcIndex , destIndex , bAppendChild )
Moves the node of the srcIndex and its child nodes to the destIndex.
notifyDataChanged( )
Synchronizes the treeview and the dataList.
removeClass( className )
Removes className from the component.
removeNode( node )
Removes a node (including child nodes) from the tree based on the node object.
removeNodeList( nodeList )
Simultaneously removes multiple nodes from the tree.
setCustomFormatter( userFunction )
Calls the customized function for each node in the TreeView.
setEventPause( evList , flag )
Disables or enables the component event.
setLabelByIndex( index , label )
Sets the label of the node.
setLabelByValue( value , label )
Sets the label of the node.
setLabelStyle( index , styleName , styleValue , applyChildNodes )
Sets the label style of the node (such as color, size, and font).
setNodeSet( nodeset , columnInfo )
Changes the current dataList bound with the treeView with another dataList.
setOpacity( value )
Sets the opacity of the component.
setPosition( left , top , mode )
Sets the position (left, top) of the component.
setReadOnly( readOnly )
Controls the "readOnly" property.
setSize( width , heigth )
Sets the size (width, height) of the component.
setStyle( propertyName , value )
Sets the style of the specified property.
setUserData( key , value )
Sets the user data in the component.
setValueByIndex( index , value )
Changes the value based on the node index.
show( displayType )
Displays the component.
spanAll( openCloseFlag )
Spans the entire tree depending on the openCloseFlag setting.
spanNode( nodeIndex , openCloseFlag , applyChildNodes )
Spans the node of the corresponding nodeIndex.
toggleClass( className )
Removes a class named className, or if there is no such a class, adds a class named className.
trigger( type , array )
Triggers a certain event registered for the component.
unbind( type , function )
Removes an event registered for the component.
visible( flag )
[deprecated] Shows/Hides the component, or sets the visible property using setStyle.

Property Detail

accessibility
[true,false] Enables the web accessibility mode. true is not to draw node lines but to add HTML properties such as aria-expanded.
alwaysDraw
[default:false, true] In case of true, draws all child items. In case of false, draws only the items lower than the showTreeDepth.
checkAllChildNodes
[default:false, true] Automatically selects all child nodes upon selection of the parent node.
checkboxDisabledFalseValue
false value of the disabled property of the checkbox. Valid when the ref of the checkbox and the ref of the checkboxDisabled ref are defined.
checkboxDisabledTrueValue
true value of the disabled property of the checkbox. Valid when the ref of the checkbox and the ref of the checkboxDisabled ref are defined.
class
Same as the class property in HTML standard. One or more classes defined in the CSS file or in the style block can be applied (through the use of the space as the separator).
WebSquare5 Engine applies different classes to different components. By defining a common class, the common class can be applied to multiple components.
dataType
[default:recursive, listed] Type of the data format (tree or list).
In case bound with a DataCollection, set listed.
defaultImage
Path of the default icon image on the node.
Default icon size - width:18px, height:20px
disabled
Disabled status
dynamicAppend
[true,false] Dynamically appends a tree.
escape
[true, false] <>&"를 HTML Escape 문자로 변환하여 화면에 표시한다.
expandedImage
Image to be displayed upon expanding
falseValue
false value of the checkbox
hierarchy
[default:false, true] Checks the parent node when the child node is selected.
If any of child nodes is not selected, the checkbox of the parent node will remain transparent. Valid when the showCheckbox is true.
id
ID of the component. Allocated as a global object. Scripts access the component through the ID.
labelclass
Class to apply to the label of each node in the tree
lineShow
[default:true, false] Shows line between the nodes in the tree.
refreshCheckboxDisableModel
[default:false, true] Refreshes the model (DataCollection or InstanceData) upon a change in the disabled status of the checkbox.
refreshCheckboxModel
[default:false, true] Refreshes the model (DataCollection or InstanceData) upon a change in the checkbox value.
scrollFix
[default:false, true] Fixes the scroll by preventing focusing upon node clicking. true is to fix, and false is to allow focusing and scrolling.
showCheckbox
[default:false, true] Shows the checkbox next to the node.
showTreeDepth
Initial depth to be displayed upon display of the tree
title
Same as the title property of HTML. Displays the Text upon the end user's hovering the mouse over the browser.
toggleButtonEvent
[default:onclick, onmousedown] Specifies the toggling moment - upon clicking of the toggling button or upon mouse clicking.
toggleEvent
[default:ondblclick, onclick, none] Event to close or open the node list.
toolTip
Tooltip provided by WebSquare5. Displays additional information of the component. Displayed upon mouse-over.다.
tooltipClass
CSS class to apply to the tooltip when the tooltipDisplay is true.
tooltipDisplay
[default:false, true] Displays the tooltip when the node label is fully displayed.
tooltipGroupClass
[default:true, false] Includes w2group style in the tooltip.
tooltipTime
Time to be taken to display the tooltip (in seconds) when the tooltipDisplay is true.
trueValue
true value of the checkbox
useDrag
[default:false, true] Uses dragging.
useHirarchySelect
[default:false, true] Selects the parent node when a child node is selected.
userData1
User-defined property. Use getUserData("userData1") to get the data.
userData2
User-defined property. Use getUserData("userData2") to get the data.
userData3
User-defined property. Use getUserData("userData3") to get the data.

Event Detail

onchange
Triggered upon selection of a different node.
Parameter
nametypedescription
oldNodenodeOld node
newNodenodeCurrently selected node
Sample
In case of ev:event="onchange(oldNode,newNode)", getSelectedLabel() and getSelectedValue() can be replaced with newNode.label and newNode.value. The node contains all information, and the developer can get only necessary information.
oncheckboxclick
Triggered upon clicking of the checkbox.
Parameter
nametypedescription
valueStringValue of the clicked node
nodeElementDocumentElement of the clicked node
indexStringIndex of the clicked node
Sample
In case of ev:event="oncheckboxclick(value, nodeElement)", click the checkbox with the bag label. var xmlStr = WebSquare.xml.indent(nodeElement); The following is an example of xmlStr: <data> <label>bag</label> <value>2</value> <depth>1</depth> <chk>T</chk> <disableChk></disableChk> <img>images/bag.gif</img> </data> value는 2이다.
onclick
Triggered upon clicking of label, checkbox, icon, or toggling button on the tree.
ondblclick
Triggered upon double-clicking of the label on the tree.
ondragleave
Triggered upon the dragging mouse pointer moving out of the pure label area (not including the icon area) of the treeview node. Valid when the useDrag is true.
Parameter
nametypedescription
eObjectEvent (e)
ondragover
Triggered when the dragging mouse pointer is over a certain node in the treeview. Valid only when the useDrag is true.
Parameter
nametypedescription
dragNodeObjectNode of the currently being dragged TreeView
dropNodeObjectNode of the dragged-over TreeView
dragControlObjectTreeView component object with the dragging event. In general dragControl is same as this;.
dropControlObjectTreeView component object in the dropping destination.
eObjectEvent (e)
ondrop
Triggered upon dragging and dropping a certain node in the treeview to another node. Valid when the useDrag is true.
Parameter
nametypedescription
dragNodeObjectNode of currently dragged treview <String> dragNode.label : Label of the dragged node <String> dragNode.value : Value of the dragged node <String> dragNode.depth : Depth of the dragged node <Object> dragNode.element : drag된 노드의 element객체
dropNodeObjectNode of the dropping destination <String> dropNode.label : Label of the dropping destination <String> dropNode.value : Value of the dropping destination <String> dropNode.depth : Depth of the dropping destination <Object> dropNode.element : drop된 노드의 element객체
dragControlTreeViewTreeView object with the dragging event
dropControlTreeViewTreeView objected of the dropping destination. Same as this within the event.
eObjectEvent (e)
Sample
// Set the useDrag as true and create a logic to add the dragged node as the sub node and delete the dragged node. <script ev:event="ondrop(dragNode,dropNode,dragControl,dropControl,e)"type="javascript"><![CDATA[ //현재의 treeview에 drag된 노드 추가 this.appendNode(dropnode,dragnode); //this 대신 dropControl로 접근해도 된다 //drag가 발생한 treeview의 drag된 노드 삭제 dragControl.removeNode( dragnode ); ]]></script>
onimageclick
Triggered upon clicking of the node icon.
Parameter
nametypedescription
valueStringalue of the clicked node
nodeElementXMLXML containing information of the clicked node
indexStringIndex string of the clicked node
onlabelclick
Triggered upon clicking of the label.
Parameter
nametypedescription
valueStringalue of the clicked node
nodeElementXMLXML containing information of the clicked node
indexStringIndex string of the clicked node
Sample
// Define arguments for the labelclick event. <script ev:event="onlabelclick(value,nodeElement,index)" type="javascript"><![CDATA[ //nodeElement 예시 ) <data index="3"> <label>bag</label> <value>2</value> <depth>1</depth> <chk>t</chk> <rowStatus statusValue="0">R</rowStatus> </data> //index의 return 예시 ) "3" ]]></script>
onrightbuttonclick
Triggered upon right-clicking the label of the treeview node. The label includes Text, image, and checkbox if any.
Parameter
nametypedescription
nodeObjectNode where right-clicking occurred. Major information is listed below. <Boolean> node.checked : Checked status of the checkbox <Number> node.depth : Node depth <Number> node.dpethIndex : Depth index of the node <Number> node.index : Node index <String> node.label : Node label <String> node.value : Node value <Object> node.parentNode : 부모 노드 객체
leftPositionNumberLeft (x) coordinate of the clicked position
topPositionNumberTop (y) coordinate of the clicked position
ontoggleclick
Triggered upon the end user's clicking of the toggling image (icon).
Parameter
nametypedescription
nodeElementDocumentXML containing information of the clicked node
indexStringIndex string of the clicked node
isRenderedbooleanRendering status of the child node
Sample
// Define argument for the toggleclick event. <script ev:event="ontoggleclick(nodeElement,index,isRendered)" type="javascript"><![CDATA[ //nodeElement 예시 ) <data index="2"> <depth>2</depth> <label>메뉴1-2</label> <value>menu1-2</value> <chk>f</chk> <rowStatus statusValue="0">R</rowStatus> <data index="3"> <depth>3</depth> <label>메뉴1-2-1</label> <value>menu1-2-1</value> <chk>f</chk> <rowStatus statusValue="0">R</rowStatus> </data> </data> //index의 return 예시 ) "3" //isRendered의 return 예시 ) true ]]></script>
onviewchange
Triggered upon selection of label, checkbox, icon, or toggling button on the treeview through the keyboard. Not triggered if the value was changed by a script.
Parameter
nametypedescription
infoJSONReturns JSON including oldNode and newNode. <JSON> info.oldNode : Previous node object (containing index, label, value, and checked status.) <JSON> info.newNode : Current node object (containing index, label, value, and checked status.)
Sample
<script ev:event="onviewchange(info)" type="javascript"><![CDATA[ //현재 선택 된 노드 var tmpCurNode = info.newNode; //이전 노드 var tmpOldNode = info.oldNode; //선택 된 노드의 주요 정보 var tmpCurLabel = tmpCurNode.label; //선택 된 노드의 label var tmpCurValue = tmpCurNode.value; //선택 된 노드의 value var tmpCurChecked = tmpCurNode.checked; //선택 된 노드의 checkbox 선택 여부 (boolean값) //이전 노드의 주요 정보 var tmpOldLabel = tmpOldNode.label; //이전 노드의 label var tmpOldValue = tmpOldNode.value; //이전 노드의 value var tmpOldChecked = tmpOldNode.checked; //이전 노드의 checkbox 선택 여부 (boolean값) ]]></script>

Method Detail

addClass( className )
Adds a class to the component.
Parameter
nametyperequireddescription
classNameStringYName of the class to add
Sample
// Add oddClass to component input1. input1.addClass("oddClass");
appendData( index , xmlArray )
Adds user data under the node of the corresponding index.
The dynamicAppend property must be set as true.
Parameter
nametyperequireddescription
indexNumberYNode index
xmlArrayArrayYOne-dimensional array containing XML data of the node to append
Sample
// (Example) Define a DataLiat, and add nodes under Favorites node using the appendData API and the XML data. //1. Define a DataList. <w2:dataList id="dc_favMenu" baseNode="list" style="" repeatNode="data" valueAttribute=""> <w2:columnInfo> <w2:column id="depth" name="depth" dataType="text"></w2:column> <w2:column id="label" name="label" dataType="text"></w2:column> <w2:column id="value" name="value" dataType="text"></w2:column> <w2:column id="chk" name="체크박스" dataType="text"></w2:column> </w2:columnInfo> <w2:data xmlns="" use="true"> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[즐겨찾기]]></label> <value><![CDATA[menu00]]></value> <chk><![CDATA[f]]></chk> </w2:row> </w2:data> </w2:dataList> //2. Define a TreeView. (Brief version) <w2:treeview dataType="listed" id="treeview1" refreshCheckboxModel="true" showCheckbox="true" dynamicAppend="true" trueValue="t" falseValue="f" style="position: relative;width: 200px;height: 400px;float:left;margin-right:10px;border:1px solid pink;"> <w2:itemset nodeset="data:dc_favMenu"> <w2:label ref="label"></w2:label> <w2:value ref="value"></w2:value> <w2:depth ref="depth"></w2:depth> <w2:checkbox ref="chk"></w2:checkbox> </w2:itemset> </w2:treeview> // 3. Add a node with appendData API. // 3.1 Define the XML data by referring to the DataList. var tmpStr = "<list>"; tmpStr += "<data><depth>2</depth><label>Menu1-1</label><value>menu1-1</value><chk>f</chk></data>"; tmpStr += "<data><depth>2</depth><label>Menu1-2</label><value>menu1-2</value><chk>f</chk></data>"; tmpStr += "</list>"; // 3.2 Create an XML. var tmpDoc = WebSquare.xml.parse(tmpStr); // 3.3 reate a parameter (XML array) for the appendData API. var tmpDocArr = WebSquare.xml.findNodes(tmpDoc,"list/data"); // 3.4 Add under the first node of the TreeView. treeview1.appendData(1,tmpDocArr); // Before calling appendData - Favorites // After calling appendData -[-] Favorites - └─ Menu1-1 - └─ Menu2-1
appendNode( parentNode , childNode )
Appends childNode under the parentNode.
Valid when the dynamicAppend is true. Mostly used to add node between the TreeViews. Receives the node through the TreeView event or a related API.
Parameter
nametyperequireddescription
parentNodeObjectYReference node
childNodeObjectYNode to add
Sample
// Example) Move a node from the left TreeView (treeview1) and drop on the right TreeView (treeview2). //1. Define a DataList and temporary data. Left TreeView - dc_menu, Right TreeView - dc_favMenu <w2:dataList id="dc_menu" baseNode="list" repeatNode="data"> <w2:columnInfo> <w2:column id="depth" name="depth" dataType="text"></w2:column> <w2:column id="label" name="label" dataType="text"></w2:column> <w2:column id="value" name="value" dataType="text"></w2:column> </w2:columnInfo> <w2:data xmlns="" use="true"> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[메뉴1]]></label> <value><![CDATA[menu1]]></value> </w2:row> <w2:row> <depth><![CDATA[2]]></depth> <label><![CDATA[메뉴1-1]]></label> <value><![CDATA[menu1-1]]></value> </w2:row> <w2:row> <depth><![CDATA[2]]></depth> <label><![CDATA[메뉴1-2]]></label> <value><![CDATA[menu1-2]]></value> </w2:row> <w2:row> <depth><![CDATA[3]]></depth> <label><![CDATA[메뉴1-2-1]]></label> <value><![CDATA[menu1-2-1]]></value> </w2:row> <w2:row> <depth><![CDATA[2]]></depth> <label><![CDATA[메뉴1-3]]></label> <value><![CDATA[menu1-3]]></value> </w2:row> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[메뉴2]]></label> <value><![CDATA[menu2]]></value> </w2:row> </w2:data> </w2:dataList> <w2:dataList id="dc_favMenu" baseNode="list" repeatNode="data"> <w2:columnInfo> <w2:column id="depth" name="depth" dataType="text"></w2:column> <w2:column id="label" name="label" dataType="text"></w2:column> <w2:column id="value" name="value" dataType="text"></w2:column> </w2:columnInfo> <w2:data xmlns="" use="true"> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[즐겨찾기]]></label> <value><![CDATA[menu00]]></value> </w2:row> </w2:data> </w2:dataList> //2. Define a TreeView. //2.1 Set the userDrag as true to move the node to the left TreeView. <w2:treeview dataType="listed" id="treeview1" useDrag="true" style="position: relative;width: 200px;height: 400px;float:left;margin-right:10px;border:1px solid orange;"> <w2:itemset nodeset="data:dc_menu"> <w2:label ref="label"></w2:label> <w2:value ref="value"></w2:value> <w2:depth ref="depth"></w2:depth> <w2:folder ref=""></w2:folder> <w2:checkbox ref=""></w2:checkbox> <w2:checkboxDisabled ref=""></w2:checkboxDisabled> <w2:image ref=""></w2:image> <w2:iconImage ref=""></w2:iconImage> <w2:selectedImage ref=""></w2:selectedImage> <w2:expandedImage ref=""></w2:expandedImage> <w2:leafImage ref=""></w2:leafImage> </w2:itemset> </w2:treeview> // 2.2 Set the dynamicAppend as true to dynamically add a node to the right TreeView. // 2.3 Set the ondrop event to add nodes by dropping the node. <w2:treeview dataType="listed" id="treeview2" dynamicAppend="true" style="position: relative;width: 200px;height: 400px;float:left;margin-right:10px;border:1px solid pink;"> <w2:itemset nodeset="data:dc_favMenu"> <w2:label ref="label"></w2:label> <w2:value ref="value"></w2:value> <w2:depth ref="depth"></w2:depth> <w2:folder ref=""></w2:folder> <w2:checkbox ref=""></w2:checkbox> <w2:checkboxDisabled ref=""></w2:checkboxDisabled> <w2:image ref=""></w2:image> <w2:iconImage ref=""></w2:iconImage> <w2:selectedImage ref=""></w2:selectedImage> <w2:expandedImage ref=""></w2:expandedImage> <w2:leafImage ref=""></w2:leafImage> </w2:itemset> <script ev:event="ondrop(dragNode,dropNode,dragControl,dropControl,e)" type="javascript"><![CDATA[ //이벤트에서 넘어오는 dropNode와 dragNode를 이용하여 현재 컴포넌트에 노드 추가 //dropNode : drop 이벤트가 일어난 노드, dragNode : drag 되어 넘어온 노드 this.appendNode(dropNode,dragNode); //drag되어 넘어 온 노드를 drag된 컴포넌트에서 삭제 //dragNode : drag 된 노드, dragControl : drag가 일어난 컴포넌트로 treeview1 이다. dragControl.removeNode( dragNode ); ]]></script> </w2:treeview>
appendXmlNodes( parentNode , xmlArray )
Adds a node under the specified parent node based on the XML data.
The dynamicAppend property must be set as true.
Parameter
nametyperequireddescription
parentNodeObjectYReference node
xmlArrayArrayYOne-dimensional array containing XML data of the node to append
Sample
// Add a node under the currently selected node based on the XML data. //1. Define a DataList. <w2:dataList id="dc_favMenu" baseNode="list" repeatNode="data" valueAttribute=""> <w2:columnInfo> <w2:column id="depth" name="depth" dataType="text"></w2:column> <w2:column id="label" name="label" dataType="text"></w2:column> <w2:column id="value" name="value" dataType="text"></w2:column> </w2:columnInfo> <w2:data xmlns="" use="true"> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[즐겨찾기]]></label> <value><![CDATA[menu00]]></value> </w2:row> </w2:data> </w2:dataList> //2. Define a TreeView. (The following is a brief version.) // To dynamically add nodes, set the dynamicAppend as true. <w2:treeview dataType="listed" id="treeview1" dynamicAppend="true" style="position: relative;width: 200px;height: 400px;float:left;margin-right:10px;border:1px solid pink;"> <w2:itemset nodeset="data:dc_favMenu"> <w2:label ref="label"></w2:label> <w2:value ref="value"></w2:value> <w2:depth ref="depth"></w2:depth> </w2:itemset> </w2:treeview> //3. Add a node under the currently selected node using appendXlNodes in the script. // 3.1 Open the selected node on the TreeView. var tmpPNode = treeview1.getSelectedNode(); // 3.2 In case no node is selected, an alert will occur. if(!tmpPNode){ alert("Select a node on the TreeView."); return; } // 3.3 Create an XML string to add. var tmpStr = "<list>"; tmpStr += "<data><depth>2</depth><label>Menu1-1</label><value>menu1-1</value><chk>f</chk></data>"; tmpStr += "<data><depth>2</depth><label>Menu1-2</label><value>menu1-2</value><chk>f</chk></data>"; tmpStr += "</list>"; // 3.4 Create an XML. var tmpDoc = WebSquare.xml.parse(tmpStr); // 3.5 Set the parameter (XML array) in the appendXmlNodes. var tmpDocArr = WebSquare.xml.findNodes(tmpDoc,"list/data"); // 3.6 Add to the selected node. treeview1.appendXmlNodes( tmpPNode , tmpDocArr );
bind( eventType , function )
Dynamically allocates events to the component.
Parameter
nametyperequireddescription
eventTypeStringYName of the event to allocate.
functionFunctionYHandler function of the event to allocate.
Sample
// Define the event handler function for the onclick event in the input component, and bind the function. input1.bind("onclick", function(e){ alert(input1.getValue();})); // Bind commObj.ev_click function for the onclick event with component input1. var commObj = {}; commObj.ev_click = function(e){ alert("click :: "+this.id); }; input1.bind("onclick", commObj.ev_click );
changeClass( oldClassName , newClassName )
Renames the class from oldClassName to newClassName.
In the default setting, only the classes added by addClass will be applied. In order to directly remove the class defined in the "class" property of the component, add the following setting in config.xml file.
<style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
oldClassNameStringYName of the class to remove
newClassNameStringYName of the class to add
Sample
// Define a class for the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following to config.xml. <style> <removeDefaultClass value="true" /> </style> // Change tmpInputClass class to tmpInputWarninClass. input1.changeClass("tmpInputClass","tmpInputWarninClass");
checkByIndex( value , checkValue , childCheck )
Finds the node of the corresponding index and sets the value of the checkbox.
trueValue and falseValue properties will be referred to, and if they are not defined, true and false will be used.
Parameter
nametyperequireddescription
valueStringYTarget node index
checkValueBoolean||StringYCheckbox value (Use true and false if trueValue and falseValue are not set.)
childCheckBooleanNSelected status of the checkbox of the child nodes
Sample
// Select the checkbox of the node of which index is 1. treeview1.checkByIndex( 1 , true); // Select the checkbox of the node of which index is 1 and its child nodes. treeview1.checkByIndex( 1 , true, true);
checkByValue( value , checkValue , childCheck )
Adds a node under the specified parent node based on the XML data.
trueValue and falseValue properties will be referred to, and if they are not defined, true and false will be used.
Parameter
nametyperequireddescription
valueStringYTarget node value
checkValueBoolean||StringYCheckbox value (Use true and false if trueValue and falseValue are not set.)
childCheckBooleanNSelected status of the checkbox of the child nodes
Sample
// Select the checkbox of the node of which value is "menu1-2". treeview1.checkByValue( "menu1-2" , true); // Select the checkbox of the node of which value is "menu1-2" and its child nodes. treeview1.checkByValue( "menu1-2" , true, true);
collapseNode( value , hierarchy )
Folds the node of the corresponding value or index. The index starts from 1.
Parameter
nametyperequireddescription
valueString||NumberYNode value or index (The index starts from 1.)
hierarchyBooleanNFolds the child node.
Sample
// Find the first node and fold it. treeview1.collapseNode( 1 , true); // Fold the node of which value is "menu1-2". treeview1.collapseNode("menu1-2"); // Fold the node of which value is "menu1-2". treeview1.collapseNode("menu1-2" , true);
disableCheckboxByValue( value , checkDisabled , childDisalbed )
Disables or enables the checkbox in the node of the corresponding value according to the checkDisabled setting.
Parameter
nametyperequireddescription
valueStringYTarget node value
checkDisabledBooleanYDisabled status of the checkbox
childDisalbedBooleanNDisabled status of the child checkbox in the selected node
Sample
// Disable the checkbox of the node of which value is "menu1". treeview1.disableCheckboxByValue("menu1",true);
// Disable the checkbox of the node of which value is "menu1" and of the child node. treeview1.disableCheckboxByValue("menu1",true,true);
expandNode( value , hierarchy )
Expands the node of the corresponding value or index which starts from 1.
Parameter
nametyperequireddescription
valueString||NumberYNode value or index (Index starts from 1.)
hierarchyBooleanNFolds the child node.
Sample
// Expand only fir first node. treeview1.expandNode( 1 , true); // Expand the node of which value is "menu1-2". treeview1.expandNode("menu1-2"); // Expand the node of which value is "menu1-2" and its child node. treeview1.expandNode("menu1-2" , true);
findNodeByIndex( index , select )
Finds the node of the corresponding index. When the second parameter is true, selects the corresponding node.
Although the node sequence changes after loading, the initially set index must be used.
Parameter
nametyperequireddescription
indexStringYNode index allocated upon initial loading
selectbooleanN[default:true, false] Selects the node.
Return
typedescription
NodeNode found
Sample
// Node sequence has not changed. Select the first node. var node1 = treeview1.findNodeByIndex(1); Return the node of which index is 1. var node1 = treeview1.findNodeByIndex(1, true); The above example will select the node of which index is 1 and get the corresponding node.
findNodeByValue( value , select )
Finds the node of the corresponding value. When the second parameter is true, selects the corresponding node.
The returned node can be used as parameters for appendData and appendNode APIs.
Parameter
nametyperequireddescription
valueStringYNode value
selectbooleanN[default:true, false] Selects the node.
Return
typedescription
NodeNode found
Sample
On the TreeView, the values of clothes, bags, and shoes are 1, 2, and 3 respectively, and the values of outer, bottom, and dress are 1-1, 1-2, and 1-3. The clothes label is selected. -[-] clothes - │ [+] outer - │ [+] bottom - │ └─ dress -[+] bags - └─ shoes var node = treeview1.findNodeByValue("1-2"); The node of the bottom label will be returned. var node = treeview1.findNodeByValue("1-2", true); The above example will select the node of the bottom label as well as get the corresponding node.
focus( )
Moves the focus to the component.
getCheckedIndexes( options )
Returns the indices of the checkbox-selected nodes as an array.
In case the node sequence changed after loading, the index may not match with the displayed node sequence.
Parameter
nametyperequireddescription
optionsJSON> options JSON containing hierarchy | <Boolean> options.hierarchy JSON containing hierarchy
<Boolean> options.hierarchy : Includes the semi-transparent selected node when using the hierarchy property.
Return
typedescription
ArrayArray of indices of the checked nodes
Sample
// The first- and the third-node checkboxes are selected. var tmpRs = treeview1.getCheckedIndexes(); // (Return) [1, 3]
getCheckedLabels( options )
Returns the labels of the checkbox-selected nodes as an array.
Parameter
nametyperequireddescription
optionsJSON> options JSON containing hierarchy | <Boolean> options.hierarchy JSON containing hierarchy
<Boolean> options.hierarchy : Includes the semi-transparent selected node when using the hierarchy property.
Return
typedescription
ArrayArray containing the labels of the checked nodes
Sample
// The first and the third checkboxes are selected, and the label if each node is Menu1 and Menu1-2 respectively. var tmpRs = treeview1.getCheckedLabels(); // (Return) ["Menu1", "Menu1-2"]
getCheckedNodes( options )
Returns an array of the nodes with the checkbox selected.
In case the node sequence changed after loading, the index may not match with the displayed node sequence.
Parameter
nametyperequireddescription
optionsJSON> options JSON containing hierarchy | <Boolean> options.hierarchy JSON containing hierarchy
<Boolean> options.hierarchy : Includes the semi-transparent selected node when using the hierarchy property.
Return
typedescription
ArrayArray of the checked nodes
Sample
// The first- and the third-node checkboxes are selected. var tmpRs = treeview1.getCheckedNodes(); // (Return) rray containing the first and the third nodes
getCheckedValues( options )
Returns the values of the checkbox-selected nodes as an array.
Parameter
nametyperequireddescription
optionsJSON> options JSON containing hierarchy | <Boolean> options.hierarchy JSON containing hierarchy
<Boolean> options.hierarchy : Includes the semi-transparent selected node when using the hierarchy property.
Return
typedescription
ArrayArray of the values of the checked nodes
Sample
// First and third checkboxes are selected and the value of each node is "m1" and "m1-2". var tmpRs = treeview1.getCheckedValues(); // (Return) ["m1", "m1-2"]
getChildData( value , hierarchy )
Returns the child data of the node of the corresponding value (in the model).
Parameter
nametyperequireddescription
valueStringYValue of the node to return the child data
hierarchyBooleanNWhether to get the data of all children
Return
typedescription
ObjectArray of the child data
Sample
On the TreeView, the values of clothes, bags, and shoes are 1, 2, and 3 respectively, and the values of outer, bottom, and dress are 1-1, 1-2, and 1-3. -[-] clothes - │ [+] outer - │ [+] bottom - │ └─ dress -[+] bags - └─ shoes var returnDoc = treeview1.getChildData('1'); returnDoc.length is 3. The following is WebSquare.xml.indent(returnDoc[0]). <data> <label>outer</label> <value>1-1</value> <depth>2</depth> <chk></chk> <excChk></excChk> <img></img> <folder>true</folder> </data>
getDataListInfo( )
Returns the list of the DataList bound with the treeview.
Return
typedescription
Object:YdataList Info
getDisabled( )
Gets the current value of the disabled property.
Return
typedescription
BooleanThe value of the disabled property.
Sample
var returnValue = componentId.getDisabled(); (Return example) false
getGenerator( )
Called by a component under the Generator component. When called, gets the parent Generator object.
Return
typedescription
ObjectParent Generator object
Sample
<w2:generator id="generator1"> <w2:trigger id="trigger1" ev:onclick="scwin.trigger1_onclick"></w2:trigger></w2:generator> scwin.trigger1.onclick = function(){ console.log(this.getGenerator());} // Click trigger1 to display the generator1 object on the console. // See https://inswave.com/jira/browse/WPF-1425.
getID( )
Gets the ID of the component.
Return
typedescription
StringID of the WebSquare5 component
Sample
// The WebSquare5 component dynamically received as a parameter can be used as shown in the following. function fn_validCheck(tmpObj){ // tmpObj has an ID of "input1". var compID = tmpObj.getID(); // (Return Example) "input1" }
getLastChildIndex( srcIndex )
Returns the index of the last child node under the node of srcIndex. (Child nodes of all depths will be searched.)
Parameter
nametyperequireddescription
srcIndexNumberYTarget node index
Return
typedescription
NumberIndex of the last child node
getOpacity( )
Gets the opacity of the component defined in CSS.
Return
typedescription
IntegerOpacity
Sample
// Apply opacity CSS to the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;opacity:0.2;"></xf:input> var returnValue = input1.getOpacity(); // "returnValue" is a real number between 0 and 1. // (Return Value) "0.2"
getParentValue( value )
Finds the parent node based on the node value, and returns the node.
If the searched node is of the highest level or no node is searched, an empty string will be returned.
Parameter
nametyperequireddescription
valueStringYNode value
Return
typedescription
StringParent node value
Sample
// The value of the highest-level node is "m1". var tmpRs = treeview1.getParentValue("menu1"); (Return) "" // The node value is "m1-1" and the parent node value is "m1". var tmpRs1 = treeview1.getParentValue("menu1"); (Return) "m1"
getPluginName( )
Gets the pluginName (or the name) of the component.
Return
typedescription
StringpluginName of the WebSquare5 component
Sample
// For a WebSquare5 object dynamically received by a common function, conditional statements can be used as shown below. var commObj = {}; commObj.fn_makeReqData = function(tmpObj){ var tmpID = tmpObj.getID(); // Component ID var tmpCompType = tmpObj.getPluginName(); // Component Type if(tmpCompType == "input"){ //..Logic.. }else if(tmpCompType == "gridView"){ //..Logic .. }else{ //..Logic.. } };
getPosition( positionName )
Gets the left or top position of the component. If set by %, the corresponding pixel value will be returned.
Parameter
nametyperequireddescription
positionNameStringY[left,top] Type of the position
Return
typedescription
NumberPosition of the component
Sample
// Apply margin CSS to the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;margin:10px;"></xf:input> var returnValue = input1.getPosition("top"); // The returnValue will be a position in pixels. // (Return Example) 10
getReadOnly( )
Gets the current setting of the readOnly property.
Return
typedescription
BooleanThe current setting of the readOnly property
Sample
var returnValue = componentId.getReadOnly(); // (Return Example) false
getSelectedIndex( )
Returns the index of the selected node.
In case the node sequence changes after loading, the index may not match with the displayed node sequence.
Return
typedescription
StringIndex of the selected node
Sample
// The highest-level node is selected. var tmpRs = treeview1.getSelectedIndex(); (Return) 1 // No node is selected. var tmpRs1 = treeview1.getSelectedIndex(); (Return) ""
getSelectedLabel( )
Returns the label of the component of the selected node.
In case no node is selected, an empty string will be returned.
Return
typedescription
StringLabel of the selected node
Sample
// No node is selected. var tmpRs = treeview1.getSelectedLabel(); // (Return) ""
getSelectedNode( )
Returns the selected node object.
The returned node can be used for appendNode and appendData. The returned node also contains information about the parent node and the child node.
Return
typedescription
ObjectSelected node - Only major information listed
<Number> index : Node index set upon initial loading <String> label : Node label <String> value : Node value <Number> depth : Node depth <boolean> checked : checked status of the checkbox <boolean> checkboxDisabled : disabled status of the checkbox <Object> parentNode : 노드의 부모 노드 (객체 구조는 return값과 동일하다) <Array> childNodes : 노드의 자식 노드가 담긴 배열 (자식 노드의 구조는 return값과 동일하다)
Sample
// Select a node of which label is "Menu1-2". var tmpRs = treeview1.getSelectedNode(); // (Return Example - with major information only) { index: 6, label: "Menu1-2", value: "m1-2", checkboxDisabled: false, checked: false, childNodes: Array[1], // Array containing the node object. depth: 2, folder: null, parentNode: WebSquare.collection.node // Node object } // Get the value of the selected node. var tmpValue = tmpRs.value; // (Return) "m1-2" // Get the value of the selected parent node. var tmpParent = tmpRs.parentNode; var tmpParentValue = tmpParent.value // (Return) "m1"
getSelectedValue( )
Returns the value of the selected node.
In case no node is selected, an empty string will be returned.
Return
typedescription
StringValue of the selected node
Sample
// No node is selected. var tmpRs = treeview1.getSelectedValue(); // (Return) ""
getSize( sizeName )
Gets the size of the component. If set by "%", the corresponding pixel value will be returned.
Parameter
nametyperequireddescription
sizeNameStringY[height, innerHeight, outerHeight, outerMarginHeight, width, innerWidth, outerWidth, outerMarginWidth] Type of the size. For the calculation of each size type, see below.
height : element.clientHeight innerHeight : element.clientHeight + padding outerHeight : element.clientHeight + padding + border outerMarginHeight : element.clientHeight + padding + border + margin width : element.clientWidth innerWidth : element.clientWidth + padding outerWidth : element.clientWidth + padding + border outerMarginWidth : element.clientWidth + padding + border + margin
Return
typedescription
NumberSize of the component
Sample
var returnValue = componentId.getSize("width"); // "returnValue" will be a size in pixels. If set by "%", the corresponding pixel value will be returned. // (Return Example) 100
getStyle( propertyName )
Gets the current value of the propertyName of the component defined in CSS.
Parameter
nametyperequireddescription
propertyNameStringYName of the property in the style
Return
typedescription
StringStyle value
Sample
// Define an Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;"></xf:input> var returnValue = input1.getStyle("width"); // (Return Example) "144px"
getStyleValue( style )
[deprecated] Use getStyle instead.
Gets the current value of the propertyName of the component defined in CSS.
Parameter
nametyperequireddescription
styleStringYName of the property defined in the style
Return
typedescription
StringValue defined in the style property. (In case of a color, the hexcode of the color will be returned.)
getTitle( )
Gets the title value.
Return
typedescription
StringTitle value
Sample
// Define the "title" for the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" title="이름 입력"></xf:input> var tmpTitle = input1.getTitle(); // (Return Example ) "Input Name"
getUserData( key )
Returns the user-defined property value set by setUserData as the user data or source (page XML).
Parameter
nametyperequireddescription
keyStringYRandom data key
Return
typedescription
StringData of the corresponding key
Sample
// Apply the customized property (eduTest) to the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" eduTest="Hello"></xf:input> input1.getUserData("eduTest"); // (Return Example) "Hello" // Use setUserData. input1.setUserData("eduTest","WebSquare"); input1.getUserData("WebSquare"); // (Return Example) "Hello"
getXPathByValue( value )
Returns the XPAth of the node of the corresponding value.
This property is to bind the data through the InstanceData or to control the data through the XML.
When bound with the DataList, XPath will be returned based on the baseNode and the repeatNode of the DataList.
Parameter
nametyperequireddescription
valueStringYNode value
Return
typedescription
StringXpath
Sample
// When bound with the DataList //1. Define a DataList. // Set the baseNode as "list" and the repeatNode as "map". <w2:dataList id="dc_menu" baseNode="list" repeatNode="map"> <w2:columnInfo> <w2:column id="depth" name="depth" dataType="text"></w2:column> <w2:column id="label" name="label" dataType="text"></w2:column> <w2:column id="value" name="value" dataType="text"></w2:column> </w2:columnInfo> <w2:data xmlns="" use="true"> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[메뉴1]]></label> <value><![CDATA[menu1]]></value> </w2:row> <w2:row> <depth><![CDATA[2]]></depth> <label><![CDATA[메뉴1-1]]></label> <value><![CDATA[menu1-1]]></value> </w2:row> <w2:row> <depth><![CDATA[1]]></depth> <label><![CDATA[메뉴2]]></label> <value><![CDATA[menu2]]></value> </w2:row> </w2:data> </w2:dataList> //2. Define a TreeView. - (The following is a brief version.) <w2:treeview dataType="listed" id="treeview1" style="position: relative;width: 200px;height: 400px;"> <w2:itemset nodeset="data:dc_menu"> <w2:label ref="label"></w2:label> <w2:value ref="value"></w2:value> <w2:depth ref="depth"></w2:depth> </w2:itemset> </w2:treeview> // Get the XPath of the node of which value is "menu1-1". var tmpRs = treeview1.getXPathByValue("menu1-1"); // (Return) "list/map[value='menu1-1']"
hasClass( className )
Checks whether the component has className received as a parameter or not.
Parameter
nametyperequireddescription
classNameStringYclassName to check
Return
typedescription
BooleanWhether the component has the class or not
Sample
// Define a class for the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> var returnValue = input1.hasClass("tmpInputClass"); // (Return Example) true
hide( )
Hides the component.
he CSS setting will be "display:none;" and "visibility:hidden;".
Sample
componentId.hide();
isLeaf( )
Returns whether the selected node is a leaf (without a child node.)
Return
typedescription
boolean[true,false] Whether it is a leaf or not
isOpen( index )
Checks the opening status of the node based on the node index.
True is to open, and false is to close. In case the node does not have a child, false will be returned.
Parameter
nametyperequireddescription
indexStringYNode index allocated upon initial loading
Return
typedescription
NodeOpening status of the node of the corresponding index
Sample
// Node sequence has not changed. Select the first node. var node1 = treeview1.isOpen(1); The opening status of the node of which index is 1 will be returned.
moveNode( srcIndex , destIndex , bAppendChild )
Moves the node of the srcIndex and its child nodes to the destIndex.
Supported only when the treeview is bound with a dataList.
Parameter
nametyperequireddescription
srcIndexNumberYTarget node index
destIndexNumberYReference node index
bAppendChildBooleanNTrue is to add as child node, and false is to add at the same level.
notifyDataChanged( )
Synchronizes the treeview and the dataList.
removeClass( className )
Removes className from the component.
In the default setting, only the classes added by addClass will be applied. In order to directly remove the class defined in the "class" property of the component, add the following setting in config.xml file.
<style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYName of the class to remove
Sample
// Define a class for the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following to config.xml. <style> <removeDefaultClass value="true" /> </style> // Remove tmpInputClass class. input1.removeClass("tmpInputClass");
removeNode( node )
Removes a node (including child nodes) from the tree based on the node object.
Parameter
nametyperequireddescription
nodeObjectYNode object
Sample
// Remove the selected node. var tmpObj = treeview1.getSelectedNode(); treeview1.removeNode(tmpObj); // Remove the node of which value is "m1-1". var tmpObj1 = treeview1.findNodeByValue("m1-1"); treeview1.removeNode(tmpObj1);
removeNodeList( nodeList )
Simultaneously removes multiple nodes from the tree.
Draws the node again on the tree. Faster than calling removeNode methods multiple times.
Parameter
nametyperequireddescription
nodeListArrayYNode as a one-dimensional array
setCustomFormatter( userFunction )
Calls the customized function for each node in the TreeView.
Parameter
nametyperequireddescription
userFunctionFunctionYCustomized function to return the formattedLabel from the received label value, formattedLabel, and node initially set.
Sample
On the treeview, the values of number, 1, 5, date, 20130530, 05302013, test, and test0 are "n0,n1,n2,d0,d1,d2,t0,t1". -[-] number - │ [+] 1 - │ [+] 5 -[-] date - └─ [+] 20130530 - └─ [+] 05302013 -[-] test - └─ [+] test0 -[-] dummy Change the style to set the child nodes of number, date, and test as red, yellow, and gray respectively, and other nodes as green. var myCustomFormatter = function(orgLabel, formattedLabel, node){ if(node.value.indexOf("n") >=0) { this.setLabelStyle(node.index, 'color', 'red', false);} else if(node.value.indexOf("d") >= 0) { this.setLabelStyle(node.index, 'color', 'yellow', false);} else if(node.value.indexOf("t") >= 0) { this.setLabelStyle(node.index, 'color', 'gray', false);} else { this.setLabelStyle(node.index, 'color', 'green', false);} return formattedLabel; } treeview1.setCustomFormatter(myCustomFormatter);
setEventPause( evList , flag )
Disables or enables the component event.
Parameter
nametyperequireddescription
evListStringNList of the events. If not specified, all user events of the component will be listed. (Enter null data.)
flagBooleanYtrue is to pause, or false is to cancel pausing.
Sample
input1.setEventPause("onclick", true); // Dynamically pauses the onclick event. input1.setEventPause("onfocus,onblur", false); // Restarts the onfocus and the onblur events. input1.setEventPause(null, true); // Pauses all user events registered for the Input component.
setLabelByIndex( index , label )
Sets the label of the node.
The index starts from 1.
Parameter
nametyperequireddescription
indexNumberYNode index
labelStringYNew label
Sample
// Change the label of the highest-level node of which position has not changed. treeview1.setLabelByIndex(1,"Favorites");
setLabelByValue( value , label )
Sets the label of the node.
Parameter
nametyperequireddescription
valueStringYNode value
labelStringYNew label
Sample
// Change the label of the node of which value is "m1". treeview1.setLabelByValue("m1","Favorites");
setLabelStyle( index , styleName , styleValue , applyChildNodes )
Sets the label style of the node (such as color, size, and font).
Parameter
nametyperequireddescription
indexNumber||StringYNode index or value
styleNameStringYName of the style to set
styleValueStringYValue of the style to set
applyChildNodesBooleanN[default:false, true] Applies the style to all child nodes of the corresponding node.
Sample
// Change the color of the label of the node ofwhich value is "menu1-1" to "orange". treeview1.setLabelStyle( "menu1-1", "color", "orange" );
setNodeSet( nodeset , columnInfo )
Changes the current dataList bound with the treeView with another dataList.
Parameter
nametyperequireddescription
nodesetStringYNew dataList id. Add the prefix "data:".
columnInfoJSONNJSON object containing label, value, depth, checkbox, and folder property values.
<JSON> columnInfo.label : label of the treeview and the column id of the dataList to bind with <JSON> columnInfo.value : value of the treeview and the column id of the dataList to bind with <JSON> columnInfo.depth : depth of the treeview and the column id of the dataList to bind with <JSON> columnInfo.checkbox : checkbox of the treeview and the column id of the dataList to bind with <JSON> columnInfo.folder : folder of the treeview and the column id of the dataList to bind with
setOpacity( value )
Sets the opacity of the component.
Parameter
nametyperequireddescription
valueNumberYOpacity value (A real number between 0 and 1)
Sample
componentId.setOpacity(0.45);
setPosition( left , top , mode )
Sets the position (left, top) of the component.
Parameter
nametyperequireddescription
leftNumberYLeft position or null.
topNumberYTop position or null.
modeStringN[defulat:absolute, delta] absolute sets the current positions as x and y, and delta adds x and y to the current positions.
Sample
// Set the top position of the component as 100 pixels. componentId.setPosition(null, 100);
setReadOnly( readOnly )
Controls the "readOnly" property. True to enable, or false to disable.
Parameter
nametyperequireddescription
readOnlyBooleanYTrue to enable, or false to disable.
Sample
// Enable the read-only. componentId.setReadOnly(true);
setSize( width , heigth )
Sets the size (width, height) of the component.
Parameter
nametyperequireddescription
widthNumberYComponent width or null
heigthNumberYComponent height or null
Sample
// Set the component height as 100 pixels. componentId.setSize(null,100);
setStyle( propertyName , value )
Sets the style of the specified property.
Parameter
nametyperequireddescription
propertyNameStringYName of the style
valueStringYValue of the style
Sample
// Set the component width as 200px. componentId.setStyle("width", "200px"); // Change the background color to olive. componentId.setStyle("background-color","olive");
setUserData( key , value )
Sets the user data in the component. If the key cannot be set for the component, corresponding logs will be displayed.
Parameter
nametyperequireddescription
keyStringYRandom data key
valueStringYRandom data key
Sample
// Setting a (key, value) pair of ("data", "WebSquare5") in the component. componentId.setUserData("data", "WebSquare"); // Some keys cannot be set for the component. componentId.setUserData("title", "WebSquare"); // (Log Example) !!!WARNING - [title] can't define as UserData
setValueByIndex( index , value )
Changes the value based on the node index.
Parameter
nametyperequireddescription
indexStringYNode index
valueStringYNew value
Sample
// Change the value of the node of which index is 2. treeview1.setValueByIndex(2,"Favorites");
show( displayType )
Displays the component.
The related CSS properties are display and visibility:show;.
Parameter
nametyperequireddescription
displayTypeStringN[default:block ,inline ,none ,""] Value of the Display property.
Sample
// Block the "display" property. componentId.show(); // Enable the "display" property in the class. componentId.show("");
spanAll( openCloseFlag )
Spans the entire tree depending on the openCloseFlag setting.
Parameter
nametyperequireddescription
openCloseFlagbooleanYCloses the child nodes.
Sample
// Close all child nodes. treeview1.spanAll(false); // Open all child nodes. treeview1.spanAll(true);
spanNode( nodeIndex , openCloseFlag , applyChildNodes )
Spans the node of the corresponding nodeIndex.
Parameter
nametyperequireddescription
nodeIndexStringYNode index or depth Added in 5.0_1.2700B.20170714.195510 to specify the dpeth and to fold or unfold all nodes of the corresponding depth. Or, when using {index:1} or {depth:1} format, use the applyChildNodes property at the second. See the example below.
openCloseFlagbooleanYWhether to open or close the node
applyChildNodesbooleanYSpans the child node.
Sample
// Toggle the node of nodeIndex 1. treeview1.spanNode(1); // Fold the node of nodeIndex 1. treeview1.spanNode(1, false); // Span the node of nodeIndex 1. treeview1.spanNode(1, true); // Fold the node of nodeIndex 1 including the child node. treeview1.spanNode(1, false, true); // Span the node of nodeIndex 1 including the child node. treeview1.spanNode(1, true, true); // Toggle the node of nodeDepth 2. treeview1.spanNode({depth:2}); // Fold all nodes of nodeDepth 2. treeview1.spanNode({depth:2}, false); // Unfold all nodes of nodeDpeth 2 as well as child nodes. treeview1.spanNode({depth:2, applyChildNodes:true}, true); // Unfold the node of nodeIndex 1 and the child nodes. treeview1.spanNode({index:1, applyChildNodes:true}, true);
toggleClass( className )
Removes a class named className, or if there is no such a class, adds a class named className.
In the default setting, only the classes added by addClass can be removed. To remove other classes, add the following setting in config.xml.
<style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYclassName to set
Sample
// Define a class for the Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following to config.xml. <style> <removeDefaultClass value="true" /> </style> // Remove tmpInputClass class. input1.toggleClass("tmpInputClass"); // Add tmpInputClass class again. input1.toggleClass("tmpInputClass");
trigger( type , array )
Triggers a certain event registered for the component.
Parameter
nametyperequireddescription
typeStringYName of the event to trigger
arrayArrayNArray of parameters to send to the event handler
Sample
// Trigger the onclick event in the input1 component. input1.trigger("onclick"); // Trigger the onviewchange event in the input component and call the event handler function by sending arguments of (1, 2). input1.trigger("onviewchange", [1,2]);
unbind( type , function )
Removes an event registered for the component.
Parameter
nametyperequireddescription
typeStringNName of the event to remove. If not specified, all events of the components will be removed.
functionFunctionNHandler function of the event to remove. If not specified, all handler functions of the event will be removed.
Sample
// Remove all events registered in the input component. input1.unbind(); // Remove all handler functions of onviewchange event registered in the input component. input1.unbind("onviewchange"); // Remove the func1 event handler of onviewchange event registered for component input1. input1.unbind("onviewchange", func1);
visible( flag )
[deprecated] Shows/Hides the component, or sets the visible property using setStyle.
Sets the visibility of the component style. In case of true, set visible. In case of false, set hidden.
Parameter
nametyperequireddescription
flagBooleanYVisibility (In case of true, set visible. In case of false, set hidden.)