kvision / pl.treksoft.kvision.data / DataContainer

DataContainer

class DataContainer<M : DataComponent, C : Component> : Widget, Container, DataUpdatable

A container class with support for observable data model.

Constructors

<init>

DataContainer(model: ObservableList<M>, binding: (Int) -> C, child: Container = VPanel(), init: DataContainer<M, C>.() -> Unit = null)

Creates DataContainer bound to given data model.

Properties

visible

var visible: Boolean

Visibility state of the current component.

Inherited Properties

draggable

var draggable: Boolean?

Determines if the current widget is draggable.

id

var id: String?

An ID attribute of generated HTML element.

parent

open var parent: Component?

Parent of the current component.

role

var role: String?

A role attribute of generated HTML element.

title

var title: String?

A title attribute of generated HTML element.

Functions

add

fun add(child: Component): Container

Adds given component to the current container.

addAll

fun addAll(children: List<Component>): Container

Adds a list of components to the current container.

clearOnUpdate

fun clearOnUpdate(): DataContainer<M, C>

Clears notification handler.

getChildren

fun getChildren(): List<Component>

Returns a list of children of the current container.

onUpdate

fun onUpdate(handler: () -> Unit): DataContainer<M, C>

Sets a notification handler called after every update.

remove

fun remove(child: Component): Container

Removes given component from the current container.

removeAll

fun removeAll(): Container

Removes all children from the current container.

update

fun update(): Unit

Updates view from the current data model state.

Inherited Functions

addCssClass

open fun addCssClass(css: String): Widget

Adds given value to the set of CSS classes generated in html code of current component.

addSurroundingCssClass

open fun addSurroundingCssClass(css: String): Widget

Adds given value to the set of CSS classes generated in html code of parent component.

afterCreate

open fun afterCreate(node: VNode): Unit

Method called after creating Snabbdom vnode.

afterDestroy

open fun afterDestroy(): Unit

Method called after destroying Snabbdom vnode.

afterInsert

open fun afterInsert(node: VNode): Unit

Method called after inserting Snabbdom vnode into the DOM.

afterPostpatch

open fun afterPostpatch(node: VNode): Unit

Method called after updating Snabbdom vnode.

clearDragDropData

open fun clearDragDropData(): Unit

Clears D&D data for the current widget. It also makes it not draggable.

getElement

open fun getElement(): Node?

Returns DOM element bound to the current component.

getElementJQuery

open fun getElementJQuery(): JQuery?

Returns JQuery element bound to the current component.

getElementJQueryD

open fun getElementJQueryD(): dynamic

Returns JQuery element bound to the current component as a dynamic type.

getSnAttrs

open fun getSnAttrs(): List<StringPair>

Returns list of element attributes in the form of a List.

getSnClass

open fun getSnClass(): List<StringBoolPair>

Returns list of CSS class names for current widget in the form of a List.

getSnHooks

open fun getSnHooks(): Hooks?

Returns list of hooks in the form of a Snabbdom Hooks object.

getSnOn

open fun getSnOn(): On?

Returns list of event handlers in the form of a Snabbdom On object.

hide

open fun hide(): Widget

Makes current widget invisible.

invoke

open operator fun invoke(vararg children: Component): Container

Operator function for adding children in a DSL style.

removeCssClass

open fun removeCssClass(css: String): Widget

Removes given value from the set of CSS classes generated in html code of current component.

removeEventListeners

open fun removeEventListeners(): Widget

Removes all event listeners from current widget.

removeSurroundingCssClass

open fun removeSurroundingCssClass(css: String): Widget

Removes given value from the set of CSS classes generated in html code of parent component.

render

open fun render(): VNode
open fun render(elementName: String): VNode
open fun render(elementName: String, children: Array<dynamic>): VNode

Renders current component as a Snabbdom vnode.

setDragDropData

open fun setDragDropData(format: String, data: String): Unit

Sets D&D data for the current widget. It also makes it draggable.

setDropTarget

open fun setDropTarget(format: String, callback: (DragEvent) -> Unit): Unit
open fun setDropTarget(formats: Set<String>? = null, callback: (DragEvent) -> Unit): Unit

Sets the current widget as a D&D drop target.

setDropTargetData

open fun setDropTargetData(format: String, callback: (String?) -> Unit): Unit

Sets the current widget as a D&D drop target with helper callback accepting String data.

setEventListener

open fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget

Sets an event listener for current widget, keeping the actual type of component.

open fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget

Sets an event listener for current widget.

show

open fun show(): Widget

Makes current widget visible.

toggleVisible

open fun toggleVisible(): Widget

Toggles visibility of current widget.

Companion Object Functions

dataContainer

fun <M : DataComponent, C : Component> Container.dataContainer(model: ObservableList<M>, binding: (Int) -> C, child: Container = VPanel(), init: DataContainer<M, C>.() -> Unit = null): DataContainer<M, C>

DSL builder extension function.