new DataTable()
An widget to to display array of data in grid table (based on HTML table).
Properties:
Name | Type | Description |
---|---|---|
columns |
Array | Column definitions. Each item is a hash that defines the aspects of column, e.g.: [ {'name': 'fieldName', 'text': 'Caption of column', 'hint': 'hint of column head', 'disableInteract': trueOrFalse, 'className': 'HtmlClassOfEachColumnCell', 'style': 'CSSInlineStyleOfEachColumnCell', 'colClassName': 'HtmlClassOfColElem', 'colStyle': 'CSSInlineStyleOfColElem'} ] name can be set to some special values to create special columns: 'OPER': operation column, 'CHECK': check box column, '*': Show all fields in data e.g.: [{'name': 'CHECK'}, {'name': '*'}, {'name': 'OPER}], or use string directly: ['CHECK', '*', 'OPER']. |
data |
Array | Data displayed in grid, each item is a hash. e.g.: [ {'id': 1, 'name': 'Smith', 'email': 'smith@ab.com'}, {'id': 2, 'name': 'Bob', 'email': null} ] |
sortFields |
Array | Fields to sort data. If field name is prefixed with '!', means sort in desc order. e.g. ['id', '!name'] |
sortFunc |
Func | Custom function to sort data. Func(dataItem1, dataItem2). Note: if data is provided by data pager, this property will be unusable. |
operColShowMode |
String | Value from Kekule.Widget.DataTable.OperColShowMode, determinate when to show operation column in data table. |
operWidgets |
Array | Array of predefined button names or widget definition hashes shown in operation column. |
showTableHead |
Bool | Whether table head row is displayed. |
enableHeadInteraction |
Bool | If this property is true, click on head cell with sort data in table automatically. |
enableActiveRow |
Bool | If this property is true, click on data row/cell will mark it as active and mouse hover will mark the row as "hover". |
Extends
Members
-
(static) Components
-
Possible child components inside data table.
Properties:
Name Type Description EDIT
DELETE
INSERT
-
(static) OperColShowMode
-
Enumeration of mode to show operation column in data table widget.
Properties:
Name Type Description NONE
ACTIVE
HOVER
ALL
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:
-
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
-
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:
-
doBindElement(element)
-
Do actual work of bindElement for descendents' overriding.
Parameters:
Name Type Description element
HTMLElement - 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:
-
doReactOperExecute(compName, rowData, rowElem, e)
-
Called when widget in operation column cell is executed.
Parameters:
Name Type Description compName
String Predefined button name. rowData
Variant rowElem
HTMLElement e
Object Normal execute event params. Descendant may override this method. -
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:
-
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:
-
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
-
getCheckedRows() → {Array}
-
Returns all checked data row elements in table.
Returns:
- Type
- Array
-
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:
-
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
-
getColCount() → {Int}
-
Returns count of columns defined by property columns.
Returns:
- Type
- Int
-
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
-
getDataRows() → {Array}
-
Returns all data row elements in table.
Returns:
- Type
- Array
-
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:
-
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
-
getParentCell(elem) → {HTMLElement}
-
Returns nearest parent cell element.
Parameters:
Name Type Description elem
HTMLElement Returns:
- Type
- HTMLElement
-
getParentHeadCell(elem) → {HTMLElement}
-
Returns nearest parent head cell element.
Parameters:
Name Type Description elem
HTMLElement Returns:
- Type
- HTMLElement
-
getParentRow(elem) → {HTMLElement}
-
Returns nearest parent data row element.
Parameters:
Name Type Description elem
HTMLElement Returns:
- Type
- HTMLElement
-
getPrevSibling()
-
Returns previous sibling widget under the same parent widget.
- Inherited From:
- Source:
-
getRowCount() → {Int}
-
Returns count of rows defined by property data.
Returns:
- Type
- Int
-
getRowData(rowElem) → {Variant}
-
Returns data associated with a row element.
Parameters:
Name Type Description rowElem
HTMLElement Returns:
- Type
- Variant
-
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
-
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
-
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
-
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
-
isPeriodicalExecuting() → {Bool}
-
Check if periodical executing is on process.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
isRowChecked(rowElem) → {Bool}
-
Returns whether check box of a row is checked.
Parameters:
Name Type Description rowElem
HTMLElement 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:
-
load(data, columns, sortFields, sortFunc)
-
Set data and sort fields at same time.
Parameters:
Name Type Description data
Array columns
Array sortFields
Array sortFunc
Func -
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:
-
reload()
-
Reload data in table.
-
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:
-
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:
-
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:
-
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:
-
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: