new TreeView()
Tree view widget.
Properties:
Name | Type | Description |
---|---|---|
selection |
Array | All selected items in tree view. |
selectedItem |
Object | Recent selected item in tree view. |
enableMultiSelected |
Bool | Whether only one tree node can be selected at same time. |
Extends
Methods
-
addClassName(classNames, affectCustomProp)
-
Add class name(s) to widget element. If affectCustomProp is true, this method will change customHtmlClassName property.
Parameters:
Name Type Description classNames
Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings. affectCustomProp
Bool Whether change customHtmlClassName property of widget. - Inherited From:
- Source:
-
addIaController(id, controller, asDefault)
-
Link a controller with this component.
Parameters:
Name Type Description id
String Unique id of controller controller
Kekule.Widget.InteractionController asDefault
Bool Whether set this controller as the default one to handle events. - Inherited From:
- Source:
-
addToSelection(items)
-
Add items to selection.
Parameters:
Name Type Description items
Variant An item element or array of items. -
appendChildItem(parentItemElem, childItemElemOrData) → {HTMLElement}
-
Append a child item with data to parentItemElem.
Parameters:
Name Type Description parentItemElem
HTMLElement Set to null to insert to root directly. childItemElemOrData
Variant HTML element or object of data. - Inherited From:
- Source:
Returns:
Element added.- Type
- HTMLElement
-
appendToElem(parentElem)
-
Append current widget to parentElem.
Parameters:
Name Type Description parentElem
HTMLElement - Inherited From:
- Source:
-
appendToWidget(parentWidget)
-
Append widget as a child to parentWidget.
Parameters:
Name Type Description parentWidget
Kekule.Widget.BaseWidget - Inherited From:
- Source:
-
blur()
-
Move focus out of widget.
- Inherited From:
- Source:
-
canUsePlaceHolderOnElem(elem) → {Bool}
-
Returns whether a placeholder widget can be bind to element to represent this widget. This method is used when auto-launching widget on HTML element. Descendants can override this method.
Parameters:
Name Type Description elem
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Bool
-
childItemsChanged(parentItemElem)
-
Notify that the child items has been removed or added to parent item. Descendants can override this method.
Parameters:
Name Type Description parentItemElem
HTMLElement - Inherited From:
- Source:
-
clearChildItems(parentItemElem)
-
Clear all child items from parent.
Parameters:
Name Type Description parentItemElem
HTMLElement - Inherited From:
- Source:
-
clearSelection()
-
Clear all items in selection.
-
collapseItem(item)
-
Collapse an item.
Parameters:
Name Type Description item
HTMLElement - Inherited From:
- Source:
-
createDecorationContent(parentElem, refElem) → {HTMLElement}
-
Create a decoration content element and insert it to parentElem before refElem.
Parameters:
Name Type Description parentElem
HTMLElement refElem
HTMLElement - Inherited From:
- Source:
Returns:
Element created.- Type
- HTMLElement
-
createElement() → {HTMLElement}
-
Create an HTML element to represent the widget. //@param {HTMLElement} parentElement
- Inherited From:
- Source:
Returns:
- Type
- HTMLElement
-
createGlyphContent(parentElem, refElem, htmlClassName) → {HTMLElement}
-
Create a glyph content container and insert it to parentElem before refElem.
Parameters:
Name Type Description parentElem
HTMLElement refElem
HTMLElement htmlClassName
String Class name added to content element. - Inherited From:
- Source:
Returns:
Element created.- Type
- HTMLElement
-
createTextContent(text, parentElem, refElem) → {HTMLElement}
-
Create an text content element and insert it to parentElem before refElem.
Parameters:
Name Type Description text
String parentElem
HTMLElement refElem
HTMLElement - Inherited From:
- Source:
Returns:
Element created.- Type
- HTMLElement
-
defineElemAttribMappingProp(propName, elemAttribName, options) → {Object}
-
Create a property that read/write attribute of HTML element.
Parameters:
Name Type Description propName
String elemAttribName
String Attribute name of HTML element. options
Hash Options to define property. If not set, default option will be used. - Inherited From:
- Source:
Returns:
Property info object added to property list.- Type
- Object
-
defineElemStyleMappingProp(propName, stylePropName, options) → {Object}
-
Create a property that read/write style property of HTML element.
Parameters:
Name Type Description propName
String stylePropName
String Property name of element.style. options
Hash Options to define property. If not set, default option will be used. - Inherited From:
- Source:
Returns:
Property info object added to property list.- Type
- Object
-
destroyElement(elem)
-
Remove the binding element from DOM tree.
Parameters:
Name Type Description elem
HTMLElement - Inherited From:
- Source:
-
dismiss(caller, callback, hideType,)
-
Dismiss a widget and cancel its modified value. Here we simply hide the widget.Descendant may override this method to do more complex job.
Parameters:
Name Type Description caller
Kekule.Widget.BaseWidget Who calls the hide method and make this widget invisible. callback
Func This callback function will be called when the widget is totally hidden. hideType,
Int value from Kekule.Widget.ShowHideType. * @param {Hash} extraOptions Extra transition options. It may contains two special fields. One is "instantly". If this field is set to true, the showing process will be executed without transition. The other is "useVisible", if true, when hiding the widget, visible property will be setted to false, otherwise the displayed property will be setted to false. - Inherited From:
- Source:
-
domElemAdded(elem)
-
Called when additional element inserted inside widget.
Parameters:
Name Type Description elem
HTMLElement - Inherited From:
- Source:
-
domElemRemoved(elem)
-
Called when element removed from widget.
Parameters:
Name Type Description elem
HTMLElement - Inherited From:
- Source:
-
doUnbindElement(element)
-
Do actual work of unbindElement for descendents' overriding.
Parameters:
Name Type Description element
HTMLElement - Inherited From:
- Source:
-
execute(invokerHtmlEvent)
-
This method should be called when the primary action is taken on widge (such as click on button, select on menu and so on).
Parameters:
Name Type Description invokerHtmlEvent
Object HTML event object that invokes executing process. - Inherited From:
- Source:
-
expandItem(item)
-
Expand an item.
Parameters:
Name Type Description item
HTMLElement - Inherited From:
- Source:
-
flash(time, caller, callback, showType,)
-
Show widget then hide it after a period of time.
Parameters:
Name Type Description time
Int In milliseconds. caller
Kekule.Widget.BaseWidget Who calls the show method and make this widget visible. callback
Func This callback function will be called when the widget is totally shown. showType,
Int value from Kekule.Widget.ShowHideType. - Inherited From:
- Source:
-
focus()
-
Focus on widget.
- Inherited From:
- Source:
-
getAllChildItems(rootItem) → {Array}
-
List all child items in order in rootItem.
Parameters:
Name Type Description rootItem
HTMLElement If not set, this method will returns all items in container. - Inherited From:
- Source:
Returns:
- Type
- Array
-
getBelongedChildItem(element) → {HTMLElement}
-
Get nearest child item. Element is a child item itself or its child element.
Parameters:
Name Type Description element
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- HTMLElement
-
getBindableElemTagNames() → {Array}
-
Returns the tag names of element can be binded with widget. Tag names should be all lowercased. The return value of null means widget can bind to any element. On the contrary, if [](empty array) is returned, the widget will be regarded as unbindable to any element. Defaultly, this method will return widget.BINDABLE_TAG_NAMES. Descendants can overwrite that variable to meet their own needs.
- Inherited From:
- Source:
Returns:
- Type
- Array
-
getBoundingClientRect(elem, includeScroll) → {Hash}
-
Returns bounding client rectangle of widget.
Parameters:
Name Type Description elem
HTMLElement includeScroll
Bool If this value is true, scrollTop/Left of documentElement will be added to result. - Inherited From:
- Source:
Returns:
{top, left, bottom, right, width, height}- Type
- Hash
-
getChildActionClass(actionName, checkSupClasses) → {Class}
-
Returns child action class associated with name for this widget.
Parameters:
Name Type Description actionName
String checkSupClasses
Bool When true, if action is not found in current widget class, super classes will also be checked. - Inherited From:
- Source:
Returns:
- Type
- Class
-
getChildAtIndex(index) → {Kekule.Widget.BaseWidget}
-
Returns child widget at index
Parameters:
Name Type Description index
Int - Inherited From:
- Source:
Returns:
-
getChildItemAt(parentItem, index) → {HTMLElement}
-
Returns child item element at index.
Parameters:
Name Type Description parentItem
HTMLElement index
Int - Inherited From:
- Source:
Returns:
- Type
- HTMLElement
-
getChildItemCount(parentItem) → {Int}
-
Returns child item count in a parent item.
Parameters:
Name Type Description parentItem
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Int
-
getChildItemRange(item1, item2, rootItem) → {Array}
-
Returns all items between item1 and item2 (including item1 and item2).
Parameters:
Name Type Description item1
HTMLElement item2
HTMLElement rootItem
HTMLElement Set to null to search in whole widget. - Inherited From:
- Source:
Returns:
- Type
- Array
-
getChildren(parentItem) → {HTMLElementCollection}
-
Returns all child item elements/
Parameters:
Name Type Description parentItem
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- HTMLElementCollection
-
getChildrenHolderElement() → {HTMLElement}
-
Returns the element that be used as root to insert child widgets. Descendants can override this method to reflect that situation.
- Inherited From:
- Source:
Returns:
- Type
- HTMLElement
-
getConfigurator() → {Kekule.Widget.BaseWidget}
-
Returns widget instance of configurator.
- Inherited From:
- Source:
Returns:
-
getCoreElement() → {HTMLElement}
-
Returns core element of widget. Usually core element is the element widget binded to, but in some cases, core element may be a child of widget element. Descendants can override this method to reflect that situation.
- Inherited From:
- Source:
Returns:
- Type
- HTMLElement
-
getDimension() → {Hash}
-
Returns dimension in px of this widget.
- Inherited From:
- Source:
Returns:
{width, height}.- Type
- Hash
-
getGlobalManager() → {Object}
-
Returns global widget manager in current document.
- Inherited From:
- Source:
Returns:
- Type
- Object
-
getIaController(id) → {Kekule.Widget.InteractionController}
-
Returns controller by id.
Parameters:
Name Type Description id
String - Inherited From:
- Source:
Returns:
-
getItemData(itemElem) → {Object}
-
Returns data previously set to itemElem.
Parameters:
Name Type Description itemElem
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Object
-
getNextSibling()
-
Returns next sibling widget under the same parent widget.
- Inherited From:
- Source:
-
getPageRect(elem, relToViewport) → {Hash}
-
Returns rectangle of widget in HTML page.
Parameters:
Name Type Description elem
HTMLElement relToViewport
Bool If this value is true, scrollTop/Left of documentElement will be substracted from result. - Inherited From:
- Source:
Returns:
{top, left, bottom, right, width, height}- Type
- Hash
-
getPrevSibling()
-
Returns previous sibling widget under the same parent widget.
- Inherited From:
- Source:
-
getStateClassName(state) → {String}
-
Get class name to set the outlook of current state. Descendants can override this method.
Parameters:
Name Type Description state
Int - Inherited From:
- Source:
Returns:
- Type
- String
-
getStyleProperty(cssPropName, element) → {Variant}
-
Get CSS property value or a style resource linked to element.
Parameters:
Name Type Description cssPropName
String CSS property name in JavaScript form. element
HTMLElement If not set, widget element will be used. - Inherited From:
- Source:
Returns:
A instance of Kekule.Widget.StyleResource or simply a CSS value.- Type
- Variant
-
getTextSelectable() → {Bool}
-
Whether the text content inside widget element can be user selected. Most widget (like tree, button) should return false, but form controls (like textbox) should return true. Descendants may override this method.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
getWidgetClassName() → {string}
-
Returns widget identity class name(s) need to add to HTML element.
- Inherited From:
- Source:
Returns:
- Type
- string
-
hasChild(widget) → {Bool}
-
Check if widget is a child of current widget.
Parameters:
Name Type Description widget
Kekule.Widget.BaseWidget - Inherited From:
- Source:
Returns:
- Type
- Bool
-
hasChildItem(parentItem) → {Bool}
-
Check if there are child under parentItem.
Parameters:
Name Type Description parentItem
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Bool
-
hasClassName(className) → {Bool}
-
Check if a class is associate with element of this widget.
Parameters:
Name Type Description className
String - Inherited From:
- Source:
Returns:
- Type
- Bool
-
hide(caller, callback, hideType,, extraOptions)
-
Hide widget.
Parameters:
Name Type Description caller
Kekule.Widget.BaseWidget Who calls the hide method and make this widget invisible. callback
Func This callback function will be called when the widget is totally hidden. hideType,
Int value from Kekule.Widget.ShowHideType. extraOptions
Hash Extra transition options. It may contains two special fields. One is "instantly". If this field is set to true, the showing process will be executed without transition. The other is "useVisible", if true, when hiding the widget, visible property will be setted to false, otherwise the displayed property will be setted to false. - Inherited From:
- Source:
-
indexOfChild(widget) → {Int}
-
Returns index of child widget. If widget is not a child, -1 will be returned.
Parameters:
Name Type Description widget
Kekule.Widget.BaseWidget - Inherited From:
- Source:
Returns:
- Type
- Int
-
initialize()
-
- Inherited From:
- Source:
-
insertChildItem(parentItemElem, childItemElemOrData, indexOrRefItem) → {HTMLElement}
-
Insert a child item with data to parentItemElem.
Parameters:
Name Type Description parentItemElem
HTMLElement Set to null to insert to root directly. childItemElemOrData
Variant HTML element or object of data. indexOrRefItem
Variant Int or HTMLElement. - Inherited From:
- Source:
Returns:
Element added.- Type
- HTMLElement
-
insertedToDom()
-
Called when widget is inserted into DOM tree.
- Inherited From:
- Source:
-
insertToElem(parentElem, refElem)
-
Insert current widget to parentElem, before refElem.
Parameters:
Name Type Description parentElem
HTMLElement refElem
HTMLElement - Inherited From:
- Source:
-
insertToWidget(parentWidget, refWidget)
-
Insert this widget as child to parentWidget, before refWidget. If refWidget not set, widget will be appended to parent.
Parameters:
Name Type Description parentWidget
Kekule.Widget.BaseWidget refWidget
Kekule.Widget.BaseWidget - Inherited From:
- Source:
-
isCaptureMouse() → {Bool}
-
Returns whether this widget is currently capturing mouse/touch event.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
isChildItem(element) → {Bool}
-
Check if element is an child item of container.
Parameters:
Name Type Description element
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Bool
-
isElementBindable(element) → {Bool}
-
Check if widget can bind to an element. Descendants can override this method to do some further check on element.
Parameters:
Name Type Description element
HTMLElement - Inherited From:
- Source:
Returns:
- Type
- Bool
-
isInDomTree() → {Bool}
-
Check if widget is in document DOM tree.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
isItemSelected(item) → {Bool}
-
Check if an item is selected.
Parameters:
Name Type Description item
HTMLElement Returns:
- Type
- Bool
-
isPeriodicalExecuting() → {Bool}
-
Check if periodical executing is on process.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
isShown(ignoreDom) → {Bool}
-
Check if widget element is visible to user.
Parameters:
Name Type Description ignoreDom
Bool If true, this method will only check CSS visibility and display property. - Inherited From:
- Source:
Returns:
- Type
- Bool
-
linkStyleResource(resOrName, element)
-
Apply style resource to self or an element.
Parameters:
Name Type Description resOrName
Variant An instance of Kekule.Widget.StyleResource or resource name. element
HTMLElement If not set, style will be set to widget element. - Inherited From:
- Source:
-
openConfigurator(callerWidget)
-
Open a popup configurator to modify settings of displayer.
Parameters:
Name Type Description callerWidget
Kekule.Widget.BaseWidget Who invokes the action. - Inherited From:
- Source:
-
removeChildItem(parentItemElem, childItemElem)
-
Remove a child item from parent.
Parameters:
Name Type Description parentItemElem
HTMLElement childItemElem
HTMLElement - Inherited From:
- Source:
-
removeChildItemAt(parentItemElem, index)
-
Remove a child item from parent.
Parameters:
Name Type Description parentItemElem
HTMLElement index
Int - Inherited From:
- Source:
-
removeClassName(classNames, affectCustomProp)
-
remove class(es) from widget element. This method not also change customHtmlClassName property.
Parameters:
Name Type Description classNames
Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings. affectCustomProp
Bool Whether change customHtmlClassName property of widget. - Inherited From:
- Source:
-
removedFromDom()
-
Called when widget is removed from DOM tree.
- Inherited From:
- Source:
-
removeFromDom()
-
Remove current widget from DOM temporarily.
- Inherited From:
- Source:
-
removeFromSelection(items)
-
Remove items from selection.
Parameters:
Name Type Description items
Variant An item element or array of items. -
removeIaController(id)
-
Unlink a controller with this component.
Parameters:
Name Type Description id
String Unique id of controller - Inherited From:
- Source:
-
removeStyleProperty(cssPropName, element)
-
Clear CSS property to widget or another element.
Parameters:
Name Type Description cssPropName
String CSS property name in JavaScript form. element
HTMLElement If not set, style will be set to widget element. - Inherited From:
- Source:
-
select(items)
-
Select items in tree view.
Parameters:
Name Type Description items
Variant An item element or array of items. -
setDimension(width, height, suppressResize)
-
Set width and height of current widget. Width and height value can be number (how many pixels) or a CSS string value directly.
Parameters:
Name Type Description width
Variant height
Variant suppressResize
Bool If this value is true, resized method will not be called. - Inherited From:
- Source:
-
setItemData()
-
Set data associated with itemElem. If data has an array field named "children", child items will automatically be added
- Inherited From:
- Source:
-
setItemText(item, text)
-
Set caption of item.
Parameters:
Name Type Description item
HTMLElement text
String -
setMouseCapture(capture)
-
Set or unset mouse capture feature of current widget.
Parameters:
Name Type Description capture
Bool - Inherited From:
- Source:
-
setStyleProperty(cssPropName, value, element)
-
Set CSS property value to widget or another element.
Parameters:
Name Type Description cssPropName
String CSS property name in JavaScript form. value
Variant A simple css value or an instance of Kekule.Widget.StyleResource or a style resource name. element
HTMLElement If not set, style will be set to widget element. UNFINISHED yet - Inherited From:
- Source:
-
show(caller, callback, showType,, extraOptions)
-
Make widget visible.
Parameters:
Name Type Description caller
Kekule.Widget.BaseWidget Who calls the show method and make this widget visible. callback
Func This callback function will be called when the widget is totally shown. showType,
Int value from Kekule.Widget.ShowHideType. extraOptions
Hash Extra transition options. It may contains a field "instantly". If this field is set to true, the showing process will be executed without transition. - Inherited From:
- Source:
-
startObservingGestureEvents(eventNames)
-
Start observing gesture events.
Parameters:
Name Type Description eventNames
Array Events need to be observed. - Inherited From:
- Source:
-
startPeriodicalExec(htmlEvent)
-
Begin periodical execution.
Parameters:
Name Type Description htmlEvent
Object HTML event that starts periodical execution. - Inherited From:
- Source:
-
stopObservingGestureEvents(eventNames)
-
Stop observing gesture events.
Parameters:
Name Type Description eventNames
Array Events need to be stopped. - Inherited From:
- Source:
-
stopPeriodicalExec()
-
Stop periodical execution.
- Inherited From:
- Source:
-
testMouseCursor(coord, e) → {Variant}
-
Get mouse cursor at a certain coord. Component can implement this function, or dispatch it to controllers.
Parameters:
Name Type Description coord
Hash 2D mouse coord e
Object event arg passed from mouse move event - Inherited From:
- Source:
Returns:
CSS cursor property value. Return '' to use default one. The return value can also be a array of cursor key words, the first legal one in current browser will be used.- Type
- Variant
-
toggleClassName(className, affectCustomProp)
-
Toggle class(es) from element. This method not also change customHtmlClassName property.
Parameters:
Name Type Description className
Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings. affectCustomProp
Bool Whether change customHtmlClassName property of widget. - Inherited From:
- Source:
-
toggleExpandStateOfItem(item)
-
Collapse expanded item or expand collapsed item.
Parameters:
Name Type Description item
HTMLElement -
toggleSelectionState(items)
-
Toggle selection state of items.
Parameters:
Name Type Description items
Variant An item element or array of items. -
unlinkStyleResource(resOrName, element)
-
Remove style resource from self or an element.
Parameters:
Name Type Description resOrName
Variant An instance of Kekule.Widget.StyleResource or resource name. element
HTMLElement If not set, style will be removed from widget element. - Inherited From:
- Source:
-
updateDimensionTransform()
-
Update widget transform based on current dimension.
- Inherited From:
- Source:
-
widgetDomStateChanged(isInDom)
-
Called when widget is inserted in or removed from HTML page DOM.
Parameters:
Name Type Description isInDom
Bool - Inherited From:
- Source:
Events
-
activate
-
Invoked when a widget is activated (such as mouse down or enter key down on button). event param of it has field: {widget}
- Inherited From:
- Source:
-
bind
-
Invoked when a widget object is bind to an HTML element. event param of it has fields: {widget, element}
- Inherited From:
- Source:
-
deactivate
-
Invoked when a widget is deactivated (such as mouse up or enter key up on button). event param of it has field: {widget}
- Inherited From:
- Source:
-
execute
-
Invoked when a widget is executed (such as click on button, select on menu and so on). event param of it has field: {widget}
- Inherited From:
- Source:
-
resize
-
Invoked when a widget's width or height changed. event param of it has field: {widget} Note: This event will only be invoked when using width/height property or setDimension method to change size. Set CSS styles directly will not fire this event.
- Inherited From:
- Source:
-
showStateChange
-
Invoked when a widget is shown or hidden. event param of it has field: {widget, isShown, isDismissed}
- Inherited From:
- Source:
-
unbind
-
Invoked when a widget object is unbind from an HTML element. event param of it has fields: {widget, element}
- Inherited From:
- Source: