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

The WidgetContainer contains widgets and manages interactions among the widgets.
The WidgetContainer is based on a two-dimensional map. The unit height is the width of the WidgetContainer divided by the number of the columns, and the unit height is the unitHeightPixel.
The WidgetContainer allows the end users to move the widgets or resize the widgets on the two dimensional map.
The WidgetContainer allows the developers to extract widget information JSON And restore them to save certain widget screen settings.

Type

uiplugin

Property Summary

cols
Number of the columns in the WidgetContainer
horizontalMargin
Horizontal margin among the widgets in pixels
id
ID of the component. Allocated as a global object. Scripts access the component through the ID.
maxUnitHeight
Maximum unit height of the widget
maxUnitHeight
Maximum unit height of the widget
maxUnitWidth
Maximum unit width of the widget
minUnitHeight
Minimum unit height of the widget
minUnitWidth
Minimum unit width of the widget
mode
Basic operation mode for the interactions among the widgets
params
User-defined data stored in the widget object
threshold
If the width of the WidgetContainer is smaller than the threshold, widgets will be placed on a single column.
unitHeightPixel
Unit height of the WidgetContainer in pixels
verticalMargin
Vertical margin of the widget in pixels
widgetMove
Allows moving of the widgets.
widgetResize
Allows resizing of the widdgets.

Event Summary

onafterwidgetclose
Triggered after a widget is closed by closeWidget.
onbeforewidgetclose
Triggerd before a widget is closed by closeWidget. If the event handler returns false, closing of the widget will be cancelled.
onclickcustombtn
Triggered upon the end user’s clicking the customized button.
onload
Triggered after all widgets contained in the WidgetContainer are loaded.
onwidgetfix
Triggered after the widget is fixed by setFixed.
onwidgetload
Triggered upon all widgets contained in the WidgetContainer are completely loaded.
onwidgetmaximize
Triggered after the widget is maximized by toggleMaximized.
onwidgetminimize
Triggered after the widget is minimized by toggleminimized.
onwidgetmove
Triggered upon a widget being moved by an API or end user’s action.
onwidgetresize
Triggered upon a widget being resized by an API or end user’s action.
onwidgetrestore
Triggered upon a minimized or maximized widget being restored.

Method Summary

addClass( className )
Adds a class to the component.
addWidgets( option )
Adds a new widgets based on the options object or option object array of the widget received.
bind( eventType , function )
Dynamically allocates events to the component.
changeClass( oldClassName , newClassName )
Renames the class from oldClassName to newClassName.
enableWidgetMove( isMovable )
Sets moving of the widget within the WidgetContainer.
enableWidgetResize( isResizable )
Allows resizing of the widget contained in the WidgetContainer.
enableWidgetTitle( showTitle )
Controls the title bars of all widgets in the WidgetContainer.
exportWidget( widgetId )
Returns the widget of the specified ID among the widgets contained in the WidgetContainer.
exportWidgets( )
REturns current widget information in the WidgetContainer as JSON data.
focus( )
Moves the focus to the component.
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.
getOpacity( )
Gets the opacity of the component defined in CSS.
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.
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).
getWidgetById( id )
Returns the widget object of the corresponding widget ID.
getWidgetByTitle( id )
Returns the widget object of the corresponding widget title. If there is no corresponding widget, null will be returned.
hasClass( className )
Checks whether the component has className received as a parameter or not.
hide( )
Hides the component.
importWidget( id , jsonObj )
Obtains information of a single widget currently existing as JSON and adds it to the WidgetContainer.
importWidgets( jsonArr , clearFlag )
Imports multiple widgets currently not existing to the WidgetContainer based on the received JSON data.
isValidPos( x , y , unitWidth , unitHeight )
Returns the validity of the location based on the received informaiton.
moveWidget( widgetId , newX , newY )
Moves the widget of the corresponding ID to the specified location (newX, newY).
redraw( )
Renders the widgets in the WidgetContainer accordingly.
removeClass( className )
Removes className from the component.
removeTitleClass( id , className )
Removes the class from the title according to the titleClass property.
removeWidgets( widgetIds )
Removes widgets of the specified IDs.
resizeWidget( widgetId , newWidth , newHeight , options )
Resizes the widget of the specified ID into the new size (newWidth, newHeight).
setCols( cols )
Sets the number of the columns in the two-dimensional map based on which the widgets are placed.
setDisabled( disabled )
Sets the disabled property.
setEventPause( evList , flag )
Disables or enables the component event.
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.
setTitleClass( id , className )
Adds a class to the title based on the titleClass property.
setUserData( key , value )
Sets the user data in the component.
show( displayType )
Displays the component.
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

cols
Number of the columns in the WidgetContainer. The WidgetContainer divides its width by the numer of the columns to determine the unit width.
horizontalMargin
Horizontal margin among the widgets in pixels
id
ID of the component. Allocated as a global object. Scripts access the component through the ID.
maxUnitHeight
Maximum unit height of the widget
maxUnitHeight
Maximum unit height of the widget
maxUnitWidth
Maximum unit width of the widget
minUnitHeight
Minimum unit height of the widget
minUnitWidth
Minimum unit width of the widget
mode
Basic operation mode for the interactions among the widgets
pushpull : Pulls up as may widgets as possible. Conflicting widgets will be pulled down.
switch : Tries to switch with the conflicting widget. However, switching is possible only with a smaller widget.
params
User-defined data stored in the widget object
Can be redefined by setParams during runtime, and can be obtained by getParams.
Moreover, this value will be extracted as ‘params’ by getWidgetInfo or exportWidgets.
threshold
If the width of the WidgetContainer is smaller than the threshold, widgets will be placed on a single column.
Moreover, upon the threshold being crossed, moving and resizing will not be allowed.
Designed for mobile environment. If not set, the widgets will be rendered in original locations although the size of the WidgetContainer gets smaller.
unitHeightPixel
Unit height of the WidgetContainer in pixels. The unitHeightPixel will become the actual height of the widget with height === 1.
verticalMargin
Vertical margin of the widget in pixels
widgetMove
Allows moving of the widgets.
widgetResize
Allows resizing of the widdgets.

Event Detail

onafterwidgetclose
Triggered after a widget is closed by closeWidget.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onafterwidgetclose(id)"><![CDATA[ alert("[onafterwidgetclose] " + id); ]]></script>
onbeforewidgetclose
Triggered before a widget is closed by closeWidget. If the event handler returns false, closing of the widget will be canceled.
Parameter
nametypedescription
idStringID of the tried widget
Sample
<script ev:event="onbeforewidgetclose(id)"><![CDATA[ alert("[onbeforewidgetclose] " + id); ]]></script>
onclickcustombtn
Triggered upon the end user’s clicking the customized button.
Parameter
nametypedescription
idStringWidget ID.
btnIdStringButton ID.
Sample
<script ev:event="onclickcustombtn(id, btnId)"><![CDATA[ alert("[onclickcustombtn widgetId:] " + id); alert("[onclickcustombtn btnId:] " + btnId); ]]></script>
onload
Triggered after all widgets contained in the WidgetContainer are loaded. Triggered after onwidgetload of all widgets occur.
Sample
onwidgetfix
Triggered after the widget is fixed by setFixed.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetfix(id)"><![CDATA[ alert("[onwidgetfix] " + id); ]]></script>
onwidgetload
Triggered upon all widgets contained in the WidgetContainer are completely loaded.
Parameter
nametypedescription
idStringWidget ID.
Sample
onwidgetmaximize
Triggered after the widget is maximized by toggleMaximized.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetmaximize(id)"><![CDATA[ alert("[onwidgetmaximize] " + id); ]]></script>
onwidgetminimize
Triggered after the widget is minimized by toggleminimized.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetminimized(id)"><![CDATA[ alert("[onwidgetminimized] " + id); ]]></script>
onwidgetmove
Triggered upon a widget being moved by an API or end user’s action.
Parameter
nametypedescription
idStringWidget ID
newRectObjectLocation information object of the widget after moving <Number> newRect.x X value of the widget after moving <Number> newRect.y Y value of the widget after moving <Number> newRect.unitWidth uitWidth of the widget after moving <Number> newRect.unitHeight unitHeight of the widget after moving
oldRectObjectLocation information object of the widget before moving <Number> oldRect.x X value of the widget before moving <Number> oldRect.y Y value of the widget before moving <Number> oldRect.unitWidth unitWidth of the widget before moving <Number> oldRect.unitHeight unitHeight of the widget before moving
Sample
<script ev:event="onwidgetmove(id, newRect, oldRect)"><![CDATA[ alert("[onbeforewidgetclose newPos:] " + id, newRect.x, newRrect.y, newRrect.unitWidth, newRrect.unitHeight); alert("[onbeforewidgetclose oldPos:] " + id, oldRect.x, oldRrect.y, oldRrect.unitWidth, oldRrect.unitHeight); ]]></script>
onwidgetresize
Triggered upon a widget being resized by an API or end user’s action.
Parameter
nametypedescription
idStringWidget ID
newRectObjectLocation information object of the widget after resizing <Number> newRect.x X value of the widget after resizing <Number> newRect.y Y value of the widget after resizing <Number> newRect.unitWidth unitWidth of the widget after resizing <Number> newRect.unitHeight unitHeight of the widget after resizing
oldRectObjectLocation information object of the widget before moving <Number> oldRect.x X value of the widget before resizing <Number> oldRect.y Y value of the widget before resizing <Number> oldRect.unitWidth unitWidth of the widget before resizing <Number> oldRect.unitHeight unitHeight of the widget before resizing
Sample
<script ev:event="onwidgetresize(id, newRect, oldRect)"><![CDATA[ alert("[onbeforewidgetclose newPos:] " + id, newRect.x, newRrect.y, newRrect.unitWidth, newRrect.unitHeight); alert("[onbeforewidgetclose oldPos:] " + id, oldRect.x, oldRrect.y, oldRrect.unitWidth, oldRrect.unitHeight); ]]></script>
onwidgetrestore
Triggered upon a minimized or maximized widget being restored.
Parameter
nametypedescription
idStringWidget ID.
Sample
<script ev:event="onwidgetrestore(id)"><![CDATA[ alert("[onwidgetrestore] " + id); ]]></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");
addWidgets( option )
Adds a new widgets based on the options object or option object array of the widget received.
In case an error occurs during widget creation, all creation will be cancel-led and rolled back.
Parameter
nametyperequireddescription
optionObjectYOptions for widget creation
<Number:N> options.x : [default:0] X value <Number:N> options.y : [default:0] Y value <Number:N> options.unitWidth : [default:1] unitWidth <Number:N> options.unitHeight : [default:1] unitHeight <String:N> options.id : [default:""] Widget ID <String:N> options.title : [default:""] Title of the widget <Boolean:N> options.hasTitleBar : [default:true] Title bar rendering status of the widget <String:N> options.src : [default:""] XML to run inwide the WFrame of the widget <Boolean:N> options.scope : [default:false] scope setting for the WFrame in the widget <Object:N> options.params : [default:undefined] User-define data to store in the widget object. <Boolean:N> options.fixed : [default:false] Fixing status of the widget. Toggling is possible by API or button input during runtime. <Boolean:N> options.resized : [default:false] Resizing of the widget. Toggling is possible by API during runtime. <Boolean:N> options.minimized : [default:false] of Minimizing of the widget Toggling is possible by API or button input during runtime. <String:N> options.maximizeFormatter : [default:null] Function or the name of the function to return the widget maximizing setting <String:N> options.buttonFormatter : [default:null] Function or the name of the function to return the button settings on the upper-right corner of the widget
Return
typedescription
Array:YArray of the added widgets
Sample
// Create a single widget. var options = {id : "widget1", title : "widget1", titleClass : "w2widget_blue", src : null, scope : true, x : 0, y : 1, unitWidth : 1, unitHeight : 1}; var newWidget = widgetContainer1.addWidgets(options); // Create multiple widgets at the same time. var optionsArr = []; optionsArr[0] = {id : "widget0", title : "widget0", src : "widget.xml", scope : true, x : 0, y : 0, unitWidth : 1, unitHeight : 1}; var newWidgets = widgetContainer1.addWidgets(optionsArr);
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");
enableWidgetMove( isMovable )
Sets moving of the widget within the WidgetContainer.
Parameter
nametyperequireddescription
isMovableBooleanYWhether to allow moving or not.
enableWidgetResize( isResizable )
Allows resizing of the widget contained in the WidgetContainer.
Parameter
nametyperequireddescription
isResizableBooleanYWhether to allow resizing or not.
enableWidgetTitle( showTitle )
Controls the title bars of all widgets in the WidgetContainer.
Parameter
nametyperequireddescription
showTitleBooleanYShows the title.
Sample
// Hide the title of all widgets in the WidgetContainer. widgetContainer1.enableWidgetTitle(false);
exportWidget( widgetId )
Returns the widget of the specified ID among the widgets contained in the WidgetContainer.
If no ID is given, null will be returned.
Related Function: exportWidgets can return information of all widgets currently contained in the WidgetContainer.
Parameter
nametyperequireddescription
widgetIdStringYWidget ID
Return
typedescription
ObjectWidget object
Sample
// Save a certain widget information using exportWidget(). var jsonObj = widgetContainer1.exportWidget('widget1'); var jsonObj2 = widgetContainer1.exportWidget('widgetContainer1_widget1'); // Output the saved JSON. console.log(jsonObj); console.log(jsonObj2);
exportWidgets( )
REturns current widget information in the WidgetContainer as JSON data.
Return
typedescription
Object[]Array of the widget objects
Sample
// Save current widgets information in jsonArr using exportWidgets(). var jsonArr = widgetContainer1.exportWidgets(); // Output the saved JSON. console.log(jsonArr);
focus( )
Moves the focus to the component.
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" }
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"
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
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"
getWidgetById( id )
Returns the widget object of the corresponding widget ID. If there is no corresponding widget, null will be returned.
Parameter
nametyperequireddescription
idStringYWidget ID
Return
typedescription
ObjectWidget of the corresponding ID
Sample
// Save a widget object of which ID is 'widget0' in the widget parameter. var widget = widgetContainer1.getWidgetById('widget0'); // If no corresponding widget is found, null will be returned. widgetContainer1.getWidgetById('NoSuchId') === null; // true;
getWidgetByTitle( id )
Returns the widget object of the corresponding widget title. If there is no corresponding widget, null will be returned.
If the widget is overlapping, the first-fund widget will be returned.
Parameter
nametyperequireddescription
idStringYWidget ID
Return
typedescription
ObjectWidget of the corresponding ID
Sample
// Save a widget object of which title is 'widget0' in the widget parameter. var widget = widgetContainer1.getWidgetByTitle('widget0'); // If no corresponding widget is found, null will be returned. widgetContainer1.getWidgetByTitle('NoSuchTitle') === null; // true;
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();
importWidget( id , jsonObj )
Obtains information of a single widget currently existing as JSON and adds it to the WidgetContainer.
The internal operation is to remove the widget of the corresponding ID and to render it again. However, the ID is maintained.
Related Function: importWidgets is to add multiple widgets not existing currently to the WidgetContainer.
Parameter
nametyperequireddescription
idStringYWidget ID
jsonObjObjectYArray of widget objects
Return
typedescription
BooleanExecution status
importWidgets( jsonArr , clearFlag )
Imports multiple widgets currently not existing to the WidgetContainer based on the received JSON data.
If the clearFlag is true, all existing widgets will be removed and a new widget will be added.
Parameter
nametyperequireddescription
jsonArrObject[]YArray of widget objects
clearFlagBooleanYWhether to remove existing widgets or not
Return
typedescription
Object[]Array of the imported widget objects
Sample
// Save jsonArr of the current widgets using exportWidgets(). var jsonArr = widgetContainer1.exportWidgets(); // Display the widgets of the jsonArr after removing the existing widgets. widgetContainer1.importWidgets(jsonArr, true);
isValidPos( x , y , unitWidth , unitHeight )
Returns the validity of the location based on the received information.
However, conflict among the widgets will not be checked. Only, the boundary and min/max limits will be checked.
Parameter
nametyperequireddescription
xNumberYX value of the widget
yNumberYY value of the widget
unitWidthNumberYunitWidth of the widget
unitHeightNumberYunitHeight of the widget
Return
typedescription
BooleanValidity of the location
Sample
//x === -1 is not a valid location so result === false will be returned. var result = isValidPos(-1, 3, 2, 3);
moveWidget( widgetId , newX , newY )
Moves the widget of the corresponding ID to the specified location (newX, newY).
If newX or newY is not valid, the existing widget will be maintained.
Rolled back to the previous status and tries again.
If successful after resolving of the conflicts, commit will be executed. Otherwise, rollback will be executed.
Upon successful moving, true will be returned. Otherwise, false will be returned.
Parameter
nametyperequireddescription
widgetIdStringYID of the widget to control.
newXNumberNNew X value of the widget
newYNumberNNew Y value of the widget
Return
typedescription
BooleanExecution result
Sample
// Move the widget0 to (2,2). widgetContainer1.moveWidget('widget0', 2, 2);
redraw( )
Renders the widgets in the WidgetContainer accordingly.
Called upon execution completion of the API. In case drag&drop is used, called upon changes in real-time locations of the widgets.
All rendering operations including oneColumn, maximize, minimize, and ghost are made by calling _renderWithRect.
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");
removeTitleClass( id , className )
Removes the class from the title according to the titleClass property.
Related Property: titleClass
Parameter
nametyperequireddescription
idStringYWidget ID
classNameStringYName of the class to remove from the widget
Sample
Dynamically remove the class ("w2widget_disable") applied to the title of the widget ("widget1"). widgetContinerID.removeTitleClass("widget1","w2widget_disable");
removeWidgets( widgetIds )
Removes widgets of the specified IDs.
The internal operation is to call _removeWidgets to actually remove the widgets. Upon successful removal, array of the deleted widget IDs will be returned.
A widget object or an array of the widget objects will enable widget removal. However, ID or ID array is recommended.
Parameter
nametyperequireddescription
widgetIdsString | String[]YArray of the widget IDs to remove
Return
typedescription
String[]Array of the removed widget IDs
Sample
var ids = ['widget0', 'widget1', 'widget2']; // Remove widgets of which IDs are widget0, widget1, and widget2. widgetContainer1.removeWidgets(ids); widgetContainer1.getWidgetById('widget0') === null // true;
resizeWidget( widgetId , newWidth , newHeight , options )
Resizes the widget of the specified ID into the new size (newWidth, newHeight).
If newWidth or newHeight is not valid, the current widget status will be maintained.
Rolled back to the previous status and tries again.
If successful after resolving of the conflicts, commit will be executed. Otherwise, rollback will be executed.
Upon successful resizing, true will be returned. Otherwise, false will be returned.
Parameter
nametyperequireddescription
widgetIdStringYID of the widget to control.
newWidthNumberNNew unitWidth of the widget
newHeightNumberNNew unitHeight of the widget
optionsObject | Object[]YOther options
Return
typedescription
BooleanExecution result
Sample
// Resize widget1 into (2,2). Even when resizeWidget is false, forced resizing is possible. widgetContainer1.resizeWidget("widget1", 2, 2, {"force" : true});
setCols( cols )
Sets the number of the columns in the two-dimensional map based on which the widgets are placed. However, the number of the columns must be the same with or larger than the current widget width.
Parameter
nametyperequireddescription
colsStringYColumns to newly set in the WidgetContainer
Sample
// The following functions when the widget width is 1, 2, 3, or 4. If the widget width is larger than 4, the following example will not function. widgetContainer1.setCols(4);
setDisabled( disabled )
Sets the disabled property. True to disable, or false not to disable.
Parameter
nametyperequireddescription
disabledBooleanYTrue to disable, or false not to disable.
Sample
// Disable the component. componentId.setDisabled(true);
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.
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");
setTitleClass( id , className )
Adds a class to the title based on the titleClass property.
Related Property: titleClass
Parameter
nametyperequireddescription
idStringYWidget ID
classNameStringYName of the class to apply to the widget
Sample
Dynamically apply a new class ("w2widget_disable") to the title area of the widget ("widget1"). widgetContinerID.setTitleClass("widget1","w2widget_disable");
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
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("");
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.)