PropertyEventMethodIndex
WebSquare.uiplugin.treeview - 5.0_4.4547B.20211124.201933

TreeView. Renders hierarchical data in a tree type. The developer can add checkboxes and icons in each node. The end user can drag-and-drop nodes between TeeView components. Various tags are used under the <div> tag at the highest level.

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. The class defined in the CSS file or style block can be applied. Multiple classes can be defined with being divided by blank space.
customFormatter
Name of the formatter that receives label, formattedLabel, and node as parameters.
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 of the component
dynamicAppend
[true,false] Dynamically appends a tree.
escape
[true, false] Converts <>&" 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
Component 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.
moveSibling
[default:false, true] When the bAppendChild is false for moveNode api, moves the child node of the srcIndex node.
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.
renderType
Rendering type.
rowHeight
Height of the tree node. (valid only when the renderType is virtual.)
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
tabIndex
The focusing order by the Tab key.
title
Same as the class property in HTML.
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
Text to be displayed upon the end user’s hovering the mouse over the component.
tooltipClass
Name of the style class to apply to the tooltip
tooltipDisplay
[default:false, true] Displays the tooltip when the node label is fully displayed.
tooltipFormatter
Name of the customized function to change the tooltip text when the tooltipDisplay property is true.
tooltipGroupClass
[default:true, false] Includes w2group style in the tooltip.
tooltipLocaleRef
Text key of the tooltip in case the tooltip text is provided in multiple languages.
tooltipShowAlways
[default:false, true] Always displays the tooltip regardless of the Text length. When this property is enabled, the tooltip will be always displayed except when the data is blank (“”).
tooltipTime
Tooltip display time. (Unit: second)
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.
oneditend
Triggered after the editing mode ends which was activated by setEditMode.
onimageclick
Triggered upon clicking of the node icon.
onlabelclick
Triggered upon clicking of the label.
onlabelover
Triggered upon the end user’s hovering the mouse over the TreeView 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).
ontooltiphide
Triggered upon the tooltip being hidden
ontooltipshow
Triggered upon the tooltip showing
onviewchange
Triggered when the value on the list is changed through keyboard input or mouse clicking.

Method Summary

addClass( className )
Adds a CSS 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 allocate an event and the handler function to the component.
changeClass( oldClassName , newClassName )
Changes the class currently applied to the corresponding WebSquare component. (Supported in all WebSquare components.)
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.
deselectNode( )
Deselects the currently selected node.
disableCheckboxByValue( value , checkDisabled , childDisabled )
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( )
Focuses the WebSquare 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 dataList bound with the component.
getDisabled( )
Returns the current value of the disabled property.
getGenerator( )
In case generated by the Generator component, returns the parent Generator object that created the component itself.
getID( )
Returns the ID of the WebSquare component.
getInitStyle( CSS )
Returns the initial style of the WebSquare 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( )
Returns the opacity of the WebSquare component. (Supported in all WebSquare components.)
getOriginalID( )
Returns the originalID of the WebSquare component. (Supported in all WebSquare components.)
getParentValue( value )
Finds the parent node based on the node value, and returns the node.
getPluginName( )
Returns the name of the WebSquare component.
getPosition( positionName )
Returns the position (left and top) of the WebSquare component. (Supported in all WebSquare components.)
getReadOnly( )
Returns the current value of the readOnly property.
getScope( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
getScopeWindow( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
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 )
Sets the size (width and height) of the WebSquare component. (Supported in all WebSquare components.)
getStyle( propertyName )
Returns the CSS setting of the WebSquare component.
getStyleValue( style )
[deprecated]
getTitle( )
Returns the title of the WebSquare component.
getUdcHome( )
Returns the path of the UDC file including the file name in which the UDC object is defined. (Supported in all WebSquare components.)
getUdcRoot( )
Returns the path of the UDC file in which the UDC object is defined. (Supported in all WebSquare components.)
getUserData( key )
Returns the value set by setUserData or directly defined by the user in the XML file.
getXPathByValue( value )
Returns the XPAth of the node of the corresponding value.
hasClass( className )
Checks whether the WebSquare component has a certain class.
hide( )
Hides the WebSquare component. (Supported in all WebSquare components.)
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.
notifyDataChanged( )
Synchronizes the treeview and the dataList.
removeClass( className )
Removes a class from the WebSquare component. (Supported in all WebSquare components.)
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 )
Pauses the event.
setInitStyle( property )
Restores the initial style of the WebSquare component.
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 in the WebSquare component. (Supported in all WebSquare components.)
setPosition( left , top , mode )
Sets the position (left, top) of the WebSquare component.
setReadOnly( readOnly )
Sets the readOnly proprety of the WebSquare component.
setShowCheckBox( )
Dynamically sets the showCheckbox.
setSize( width , height )
Sets the size (width, height) of the WebSquare component.
setStyle( propertyName , value )
Sets the CSS of the WebSquare component.
setUserData( key , value )
Sets random data in the WebSquare component. (Supported in all WebSquare components.)
setValueByIndex( index , value )
Changes the value based on the node index.
show( displayType )
Shows the WebSquare component on the page. (Supported in all WebSquare components.)
spanAll( openCloseFlag )
Spans the entire tree depending on the openCloseFlag setting.
spanNode( nodeIndex , openCloseFlag , applyChildNodes )
Spans the node of the corresponding nodeIndex.
toggleClass( className )
Adds or removes a CSS class to or from a WebSquare component. (Supported in all WebSquare components.)
trigger( type , array )
Triggers the specified event in the WebSquare component.
unbind( type , function )
Removes the specified event from the WebSquare component.
visible( flag )
[deprecated]

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. The class defined in the CSS file or style block can be applied. Multiple classes can be defined with being divided by blank space.
WebSquare5 Engine applies different classes to different components. By defining a common class, the common class can be applied to multiple components.
customFormatter
Name of the formatter that receives label, formattedLabel, and node as parameters.
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
Disable the component. (Options) "false" (Default) Not disable the component. "true" Disable the component.
dynamicAppend
[true,false] Dynamically appends a tree.
escape
[true, false] Converts <>&" into HTML Escape characters. (Options) "true" (Default) : Not convert into HTML Escape characters. "false" : Decodes HTML escape characters as tags.
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
Component ID
The component ID is allocated as a global object. The script can access each object through the component 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.
moveSibling
[default:false, true] When the bAppendChild is false for moveNode api, moves the child node of the srcIndex node.
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.
renderType
Rendering type.
Values: table (Default), virtual
rowHeight
Height of the tree node. (valid only when the renderType is virtual.) (Unit: px)
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
tabIndex
The focusing order by the Tab key.
Same as the tabindex property in HTML.
title
Same as the title property in HTML. The title is displayed upon the end user’s moving the mouse over the component. Generally used to support web accessibility.
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
Text to be displayed upon the end user’s hovering the mouse over the component. Provided by WebSquare, and specifies additional information of the component.
tooltipClass
Name of the style class to apply to the tooltip Valid in case of tooltipDisplay="true". (Related Property) tooltipDisplay="true"
tooltipDisplay
[default:false, true] Displays the tooltip when the node label is fully displayed.
tooltipFormatter
Name of the customized function to change the tooltip text when the tooltipDisplay property is true.
The user-defined function receives label, nodeIndex, and isOverflow, and returns the string to display as the tooltip.
tooltipGroupClass
[default:true, false] Includes w2group style in the tooltip.
tooltipLocaleRef
Text key of the tooltip in case the tooltip text is provided in multiple languages.
When there is no text for the key, "global_undefined" will be displayed on the screen.
tooltipShowAlways
[default:false, true] Always displays the tooltip regardless of the Text length. When this property is enabled, the tooltip will be always displayed except when the data is blank (“”).
tooltipTime
Tooltip display time. (Unit: second)
Valid in case of tooltipDisplay="true". (Related Property) tooltipDisplay="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("userData3") to get the data. // Example getUserData("userData1");
userData2
User-defined property. Use getUserData("userData2") to get the data. // Example getUserData("userData2");
userData3
User-defined property. Use getUserData("userData3") to get the data. // Example getUserData("userData3");

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> The value is 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>
oneditend
Triggered after the editing mode ends which was activated by setEditMode.
Parameter
nametypedescription
infoObjectObject containing old label value, new label value, and index of the node subject to editing <Number> info.index : Index of the node subject to editing <String> info.oldValue : Old label value <String> info.newValue : New label value
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>
onlabelover
Triggered upon the end user’s hovering the mouse over the TreeView label.
Parameter
nametypedescription
indexStringIndex string currently moused over
nodeElementDocumentXML containing the node information currently moused over
valueStringValue string of the node currently moused over
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>
ontooltiphide
Triggered upon the tooltip being hidden
ontooltipshow
Triggered upon the tooltip showing
onviewchange
Triggered when the value on the list is changed through keyboard input or mouse clicking.
In case the change was made by a script, the event will not be triggered. (Similar to the native onchange event.)
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 CSS class to the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
classNameStringYName of the class to add
Sample
// (Example) // Add oddClass to input1 component. 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 allocate an event and the handler function to the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
eventTypeStringYEvent to allocate
functionFunctionYHandler function of the event
Sample
// (Example 1) // Define a function for the onclick event of input1. input1.bind("onclick", function(e){ alert(input1.getValue();})); // (Example 2) // Define commObj.ev_click function in advance. var commObj = {}; commObj.ev_click = function(e){ alert("click :: "+this.id); }; // Dynamically allocate onclick event and the handler function to input1 component. input1.bind("onclick", commObj.ev_click );
changeClass( oldClassName , newClassName )
Changes the class currently applied to the corresponding WebSquare component. (Supported in all WebSquare components.)
Only the classes added by addClass can be changed.
In order to remove classes directly defined in the class propert of the WebSquare component, add the following in config.xml. // Add the following in config.xml.
Parameter
nametyperequireddescription
oldClassNameStringYClass to change
newClassNameStringYClass to newly use
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following in config.xml. <style> <removeDefaultClass value="true" /> </style> // Change the class. // 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);
deselectNode( )
Deselects the currently selected node.
disableCheckboxByValue( value , checkDisabled , childDisabled )
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
childDisabledBooleanNDisabled 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( )
Focuses the WebSquare component. (Supported in all WebSquare components.)
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 : Specifies whether to include the semi-transparent nodes when using the hierarchy property. <Boolean> options.excludeRoot : Specifies whether to exclude the root node.
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 : Specifies whether to include the semi-transparent nodes when using the hierarchy property. <Boolean> options.excludeRoot : Specifies whether to exclude the root node.
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 : Specifies whether to include the semi-transparent nodes when using the hierarchy property. <Boolean> options.excludeRoot : Specifies whether to exclude the root node.
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 : Specifies whether to include the semi-transparent nodes when using the hierarchy property. <Boolean> options.excludeRoot : Specifies whether to exclude the root node.
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 dataList bound with the component.
Return
typedescription
ObjectReturns nodeset, label, and value id as an object.
Sample
// Example treeview1.getDataListInfo();
getDisabled( )
Returns the current value of the disabled property. (Supported in all WebSquare components.)
Return
typedescription
BooleanValue of the disabled property
Sample
// (Example) Check the current value of the disabled property. var returnValue = componentId.getDisabled(); // (Return Example) false
getGenerator( )
In case generated by the Generator component, returns the parent Generator object that created the component itself. (Supported in all WebSquare components.)
Return
typedescription
ObjectParent Generator object
Sample
// (Example) The Generator (parent) create a Trigger (child). <w2:generator id="generator1"> <w2:trigger id="trigger1" ev:onclick="scwin.trigger1_onclick"></w2:trigger></w2:generator> // In the example below, upon the end user’s clicking the Trigger 1, the generator1 object will be displayed on the console. scwin.trigger1.onclick = function(){ console.log(this.getGenerator());}
getID( )
Returns the ID of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringWebSquare component ID
Sample
// Upon dynamically receiving a WebSquare component, the ID can be checked as shown below. function fn_validCheck(tmpObj){ var compID = tmpObj.getID(); } // If the tmpObj in the above example has "input1" ID. // (Return) "input1"
getInitStyle( CSS )
Returns the initial style of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
CSSStringNProperty (If not specified, all properties will be displayed.)
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( )
Returns the opacity of the WebSquare component. (Supported in all WebSquare components.)
The Engine returns the opacity value of the CSS.
Return
typedescription
IntegerOpacity
Sample
// Apply the opacity CSS to the InputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;opacity:0.2;"></xf:input> // Return the opacity of the InputBox. var returnValue = input1.getOpacity(); // A real number between 0 and 1 will be returned. // (Return) "0.2"
getOriginalID( )
Returns the originalID of the WebSquare component. (Supported in all WebSquare components.)
The originalID is valid when the scope function is in use.
For scope="true" WFrame, component IDs inside the WFrame is changed with the prefix(wframeID + "_") being added before the ID given by the user (originalID).
The originalID means the ID before the prefix being added.
Return
typedescription
StringoriginalID of the component
Sample
// An example of multi-WFrame page // Main page with a WFrame (main.xml) <w2:wframe id="wframe1" src="text.xml" scope="true"/> // Source page to be contained in the WFrame (text.xml) <w2:textbox id="textbox1"/> // (Example) Check the Id and the original ID in the script of text.xml // Run getID. textbox1.getID(); // "wframe1_textbox1" is returned. // Run getOriginalID. textbox1.getOriginalID(); // "textbox1" is returned.
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( )
Returns the name of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringName of the WebSquare component (pluginName)
Sample
// When a common function dynamically receives a WebSQuare object as shown below, different actions can be made for each component type. var commObj = {}; commObj.fn_makeReqData = function(tmpObj){ var tmpID = tmpObj.getID(); // Component ID var tmpCompType = tmpObj.getPluginName(); // Component name if(tmpCompType == "input"){ //..Logic.. }else if(tmpCompType == "gridView"){ //..Logic .. }else{ //..Logic.. } };
getPosition( positionName )
Returns the position (left and top) of the WebSquare component. (Supported in all WebSquare components.)
When the position is set in 0%, the value will be converted into %.
Parameter
nametyperequireddescription
positionNameStringY[left, top] Position type
Return
typedescription
NumberPosition of the component
Sample
// CSS margin is applied to the Input component as shown below. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;margin:10px;"></xf:input> // (Example) Check the top value of the InputBox. var returnValue = input1.getPosition("top"); // Position value in pixels will be returned. // (Return) 10
getReadOnly( )
Returns the current value of the readOnly property. (Supported in all WebSquare components.)
Return
typedescription
BooleanThe current setting of the readOnly property
Sample
// Example to check the readOnly setting of the component. var returnValue = componentId.getReadOnly(); // (Return Example) false
getScope( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
For scope="true" WFrame, null will be returned.
Return
typedescription
ObjectWFrame object or null
Sample
// (Example) // The main page has wframe1 which contains wframe1 which also contains wframe11. // The source page of wframe11 has textbox1. textbox1.getScope(); // (Return Example) wframe11 object
getScopeWindow( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
If not a child of a scope="true" WFrame, a global window object will be returned.
Return
typedescription
ObjectScope object of the WFrame or a global window object
Sample
// (Example) // The main page has wframe1 which contains wframe1 which also contains wframe11. // The source page of wframe11 has textbox1. var scope = textbox1.getScopeWindow(); scope.wframe11 === textbox1.getScope(); // true
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 )
Sets the size (width and height) of the WebSquare component. (Supported in all WebSquare components.)
If set in %, values will be converted into pixels.
Parameter
nametyperequireddescription
sizeNameStringYSize types. For calculation of each size type, see the 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"); // (Return Example) 100 // Values are in pixels. // If set in %, values will be converted into pixels.
getStyle( propertyName )
Returns the CSS setting of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyNameStringYCSS property to return
Return
typedescription
StringCSS value
Sample
// Define an Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;"></xf:input> // (Example) Check the width of the InputBox above. var returnValue = input1.getStyle("width"); // (Return) "144px"
getStyleValue( style )
[deprecated]
Use getStyle instead.
Returns the current CSS applied to the WebSquare component.
Parameter
nametyperequireddescription
styleStringYCSS property to return
Return
typedescription
StringCSS value (Colors are returned in HexCode.)
getTitle( )
Returns the title of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringTitle
Sample
// In the following example, the Title is “Input Name”. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" title="이름 입력"></xf:input> var tmpTitle = input1.getTitle(); // (Return Example) “Enter your name.”
getUdcHome( )
Returns the path of the UDC file including the file name in which the UDC object is defined. (Supported in all WebSquare components.)
The file name includes .xml. In order to get the file path without .xml, use getUdcRoot.
When called by a WebSquare component, not a UDC object, “undefined” will be returned.
Return
typedescription
StringUDC file path (For others than the UDC, undefined will be returned.)
Sample
// Example // UDC file path is /a/b/udc.xml. // Page XML is /a/c/main.xml. // UDC ID is udc1. udc1.getUdcHome(); // (Result) /a/b/udc.xml
getUdcRoot( )
Returns the path of the UDC file in which the UDC object is defined. (Supported in all WebSquare components.)
Not contains the file name. In order to get a path including the file name, use getUdcHome.
When called by a WebSquare component, not a UDC object, “undefined” will be returned.
Return
typedescription
StringUDC file path (For others than the UDC, undefined will be returned.)
Sample
// Example // UDC file path is /a/b/udc.xml. // Page XML is /a/c/main.xml. // UDC ID is udc1. udc1.getUdcHome(); // (Execution Result) /a/b/
getUserData( key )
Returns the value set by setUserData or directly defined by the user in the XML file. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
keyStringYData key
Return
typedescription
StringValue for the given key
Sample
// (Example) Setting the user property (setTest) in the InputBox <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" setTest="Hello"></xf:input> // Returns the value of the setTest property. input1.getUserData("setTest"); // (Return) "Hello" // Set 'valueTest' (key) and 'WebSquare' (data) through setUserData. input1.setUserData("valueTest","WebSquare"); // Returns the value of the setTest property. input1.getUserData("WebSquare"); // (Return) "WebSquare"
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 WebSquare component has a certain class. (Supported in all WebSQuare components.)
Parameter
nametyperequireddescription
classNameStringYName of the class to check
Return
typedescription
BooleanWhether the class exists or not
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> var returnValue = input1.hasClass("tmpInputClass"); // (Return) true
hide( )
Hides the WebSquare component. (Supported in all WebSquare components.)
display:none; or visibility:hidden; CSS is applied.
Sample
// (Example) Hide the component. 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.
notifyDataChanged( )
Synchronizes the treeview and the dataList.
removeClass( className )
Removes a class from the WebSquare component. (Supported in all WebSquare components.)
Only the classes added by addClass can be removed.
In order to remove classes directly defined as a property of the component, add the following in config.xml. // Add the following in config.xml. <style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYName of the class to remove
Sample
// If the class is directly defined as an InputBox property. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // In the config.xml file, add the following. <style> <removeDefaultClass value="true" /> </style> // Classes can be removed by removeClass. 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 )
Pauses the event. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
evListStringNList of the events to pause. (in case of null, all events of the corresponding WebSquare component is paused or restarted.)
flagBooleanYWhether to pause the event or not.
true: Pause. false: Not pause.
Sample
// (Example 1) // Pause the onclick event. input1.setEventPause("onclick", true); // (Example 2) // Restart the onfocus and the onblur events. input1.setEventPause("onfocus,onblur", false); // (Example 3) // Pause all events registered in input1. input1.setEventPause(null, true);
setInitStyle( property )
Restores the initial style of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyStringNCSS property (If not spcified, all properties will be restored.)
Sample
// (Example) group1.setInitStyle();
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
Sample
// The new dataList ID is dataList1. var columnInfo={}; columnInfo.label = "newVal" // The column id of the dataList is newVal. columnInfo.value = "newLab" // The column id of the dataList is newLab. columnInfo.depth = "newDep" // The column Id of the dataList is newDep. columnInfo.checkbox = "newChk" // The column Id of the dataList is newChk. columnInfo.folder = "newFol" // The column Id of the dataList is newFol. treeview1.setNodeSet( "data:dataList1" , columnInfo ); // The treeView id is treeview1.
setOpacity( value )
Sets the opacity in the WebSquare component. (Supported in all WebSquare components.)
The engine sets the opacity property (of CSS).
Parameter
nametyperequireddescription
valueNumberYOpacity (Real number between 0 and 1)
Sample
// (Example) Set the opacity as 0.45. componentId.setOpacity(0.45);
setPosition( left , top , mode )
Sets the position (left, top) of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
leftNumberYLeft position value or null
topNumberYTop position value or null
modeStringNPosition setting method. [default: absolute, delta]
absolute: The inputted value becomes the position. delta: The inputted value is added to the current position.
Sample
// (Example) Set the top position as 100px. componentId.setPosition(null, 100);
setReadOnly( readOnly )
Sets the readOnly proprety of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
readOnlyBooleanYSetting of the readOnly property. (“true”: Used. “false”: Not used.)
Sample
// Set the readOnly property as true. componentId.setReadOnly(true);
setShowCheckBox( )
Dynamically sets the showCheckbox.
setSize( width , height )
Sets the size (width, height) of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
widthNumberYWidth of the component or null.
heightNumberYHeight of the component or null.
Sample
// (Example) Set the height of the component as 100px. componentId.setSize(null,100);
setStyle( propertyName , value )
Sets the CSS of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyNameStringYCSS property to set.
valueStringYValue to set as the specified CSS property
Sample
// (Example 1) Set the width as 200px. componentId.setStyle("width", "200px"); // (Example 2) Set the background as olive. componentId.setStyle("background-color","olive");
setUserData( key , value )
Sets random data in the WebSquare component. (Supported in all WebSquare components.)
Enter key values supported by the component. In case a key value not supported by the component is entered, corresponding logs will be displayed.
Parameter
nametyperequireddescription
keyStringYData key to set
valueStringYDefined data value
Sample
// Set 'data' key and 'WebSquare' value in the component. componentId.setUserData("data", "WebSquare"); // The key must be supported in the component. componentId.setUserData("title", "WebSquare"); // Following logs will be displayed. // !!!WARNING - [title] can't be defined 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 )
Shows the WebSquare component on the page. (Supported in all WebSquare components.)
Sets the display property as specified and applies "visibility: show;" CSS.
Parameter
nametyperequireddescription
displayTypeStringNCSS display setting to apply.
block : Uses “display: block;”. (Default) inline : display: inline; none : display: none; "" : Restores to the previous display setting.
Sample
// (Example) display: block; componentId.show(); // (Example) Restore the previous display setting. 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
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}); // Toggle the node of nodeDepth 2. treeview1.spanNode({depth:2}, false); // Span the node of nodeDpeth 2 and its child nodes. treeview1.spanNode({depth:2, applyChildNodes:true}, true);
toggleClass( className )
Adds or removes a CSS class to or from a WebSquare component. (Supported in all WebSquare components.)
Removes the class from the WebSquare component.
If the WebSquare component does not have the specified class, adds the class.
Only the classes added by addClass can be removed.
In order to remove classes directly defined as a property of the component, add the following in config.xml. // Add the following in config.xml. <style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYClass to add or remove
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following in config.xml. <style> <removeDefaultClass value="true" /> </style> // Remove tmpInputClass class. input1.toggleClass("tmpInputClass"); // Add the (previously removed) tmpInputClass. input1.toggleClass("tmpInputClass");
trigger( type , array )
Triggers a certain event in the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
typeStringYEvent to trigger
arrayArrayNArray of parameters to send to the event handler
Sample
// (Example 1) // Trigger the onclick event in input1 component. input1.trigger("onclick"); // (Example 2) // Trigger the onviewchange event in input1, and send (1, 2) parameter to the handler function. input1.trigger("onviewchange", [1,2]);
unbind( type , function )
Removes the event from the component. (Supported in all WebSquare component.)
Parameter
nametyperequireddescription
typeStringNEvent to remove. (If not specified, all events of the component will be removed.)
functionFunctionNHandler function of the event to remove. (If not specified, all handler functions of the event will be removed.)
Sample
// (Example 1) // Remove all events registered in the input1 component. input1.unbind(); // (Example 2) // Remove all handler functions for the onviewchange event of the input1 component. input1.unbind("onviewchange"); // (Example 3) // Remove func1 for the onviewchange event of the input1 component. input1.unbind("onviewchange", func1);
visible( flag )
[deprecated]
Use show/hide or setStyle instead.
The Engine sets the CSS visibility property.
Parameter
nametyperequireddescription
flagBooleanYCSS visibility setting
true : visibility: visible; false : visibility: hidden;