TreeView Class
UI TreeView element.
Constructor
TreeView
()
Item Index
Methods
- addCleanFunc
- addControl
- addToContextMenu
- canDrop
- cleanUp
- dragEnter
- dragLeave
- dragOver
- drop
- editCancel
- editSave
- editStart
- filterSource
- formatStatus
- getDiv
- getDropMode
- getParentControl
- getPersistentStateRootControl
- getPersistentStateRootKey
- getRealScrollOffset
- localListen
- localPromise
- makeDraggable
- raiseEvent
- requestFrame
- requestFrameMM
- requestIdle
- requestTimeout
- restorePersistentStates
- restoreState
- setDragElementData
- setRealScrollOffset
- setStatus
- storePersistentStates
- storeState
- thenWithProgress
Methods
addCleanFunc
-
func
Add function to be called once during Control cleanUp
Parameters:
-
func
FunctionFunction to add
addControl
-
controlClass
-
initParams
Creates a new sub-control.
Parameters:
-
controlClass
StringClass of the new control.
-
initParams
ObjectInitialization parameters.
Returns:
The new control.
addToContextMenu
-
Array
Adds item(s) to control context menu.
Parameters:
-
Array
Array | | Functionof menu items to add, or function returning menu items.
canDrop
-
Event
Control is allow drop objects.
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
Returns:
true if dragged object can be dropped here
cleanUp
()
Should clean up all the control stuff, i.e. mainly unlisten events.
dragEnter
-
Event
Handle drag enter operation
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
dragLeave
-
Event
Handle drag leave operation
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
dragOver
-
Event
Handle drag over operation
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
drop
-
Event
Handle drop operation
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
editCancel
()
Cancels the current inline edit.
editSave
()
Confirms the current inline edit.
editStart
()
Starts inline editing of the focused item.
filterSource
-
phrase
Filters dataSource based on given criteria (used when searching/filtering items within, e.g. via search bar)
Parameters:
-
phrase
Stringstring phrase to filter
Returns:
String message or object with detailed data
formatStatus
()
Object
Format status text in this callback, when using object with detailed data.
Returns:
String message or object with detailed data
getDiv
-
integer
Returns the div at the corresponding item index, or null if no div contains the item.
Parameters:
-
integer
ObjectIndex of list
Returns:
HTMLElement|null Div at the corresponding item index if it exists.
getDropMode
-
Event
Gets new drop mode
Parameters:
-
Event
Objectobject. dataTransfer property is used for D&D operations
Returns:
Drop mode
getParentControl
-
topParentCtrl
Returns the first ancestor in the HTML DOM tree, that has controlClass and data-id. Searching is stopped on topParentCtrl, if defined.
Parameters:
-
topParentCtrl
ObjectControlClass of the top parent, where to stop searching.
Returns:
Parent Control or undefined if there's no parent.
getPersistentStateRootControl
()
Object
Returns control to decide which subcontrols should be stored e.g. Multiview component overrides this as it stores states only for the active control/view
Returns:
object control
getPersistentStateRootKey
()
String
Returns root key string under which the values are stored in persistent.JSON file on the disk.
Returns:
store key id
getRealScrollOffset
()
Returns the top scrolled item information/offset, so that it can be restored in case LV formatting/size is changed (and thus scroll offset of the canvas wouldn't match).
Returns:
Object Information about the scrolled position
localListen
-
object
-
event
-
func
-
[bool]
This method is pretty similar as app.listen(), but app.unlisten() is called automatically in Control.cleanUp()
Parameters:
-
object
ObjectObject where to set listener
-
event
StringEvent of the listener
-
func
MethodMethod for callback dispatch
-
[bool]
Method optionalCapture?
localPromise
-
object
This method is supposed to automatically cancel running promises when component is going to destroy.
Parameters:
-
object
PromisePromise
Returns:
makeDraggable
-
Object
-
true
Control is allow drag object
Parameters:
-
Object
Objectto enable/disable drag
-
true
Boolwhen object can be dragged. Default is true
raiseEvent
-
eventName
-
details
-
[isCancelable]
-
[canBubble]
-
sender
Raise the event on the Control
Parameters:
-
eventName
StringName of the event
-
details
ObjectCustom parameters to be sent with the event
-
[isCancelable]
Boolean optionalWhether the event can be canceled.
-
[canBubble]
Boolean optionalWhether the event can bubble.
-
sender
Objectof the event. Container by default.
Returns:
Success. If 'false', the event was canceled.
Example:
if (!this.raiseEvent('selecting', {
tabIndex: value,
oldTabIndex: oldSelected
}, true))
return; // canceled, do not change selection
requestFrame
-
callback
-
[callbackID]
Request an animation frame in the control context. If the control has been cleaned up, then the callback will not execute.
Parameters:
-
callback
FunctionCallback to run.
-
[callbackID]
String optionalOptional ID for callback, so that multiple instances of the callback do not execute at the same time.
Example:
this.requestFrame(function () {
// this callback will be executed at a maximum of your monitor's natural refresh rate.
}, "myUniqueFrameCallbackName");
requestFrameMM
-
callback
-
[callbackID]
Request an animation frame in the control context, with the same features as requestAnimationFrameMM(). If the control has been cleaned up, then the callback will not execute.
Parameters:
-
callback
FunctionCallback to run.
-
[callbackID]
String optionalOptional ID for callback, so that multiple instances of the callback do not execute at the same time.
Example:
this.requestFrame(function () {
// this callback will be executed at a maximum of your monitor's natural refresh rate when focused, maximum of 30 fps when not focused, and maximum of 2 fps when window is not visible.
}, "myUniqueFrameCallbackName");
requestIdle
-
callback
-
[callbackID]
-
[useFirst]
Calls requestIdleCallback, cancels the previous sheduled callback on cleanup or multiple calls
Parameters:
-
callback
FunctionCallback, which should be called when idle
-
[callbackID]
String optionalString name, which identifies the callback. If present, it cancels the previous sheduled callback
-
[useFirst]
Boolean optionalValid only if callbackID is present, if true, previous unfinished timer is finished and the last is revoked
requestTimeout
-
callback
-
timeMS
-
[callbackID]
-
[useFirst]
Calls setTimeout, cancels the previous sheduled callback on cleanup or multiple calls
Parameters:
-
callback
FunctionCallback, which should be called after timeout
-
timeMS
IntegerTimeout, in ms
-
[callbackID]
String optionalString name, which identifies the callback. If present, it cancels the previous sheduled callback
-
[useFirst]
Boolean optionalValid only if callbackID is present, if true, previous unfinished timer is finished and the last is revoked
restorePersistentStates
()
Restores persistent (class) states for the control class and all subcontrols, this stores global (class) state (is same for all instances of the control)
restoreState
-
fromObject
Restores state of the control and all its subcontrols having data-id specified.
Parameters:
-
fromObject
Objecthierarchical object including states of the control and the subcontrols
setDragElementData
-
Object
-
Drag
Set details for dragged element
Parameters:
-
Object
Objectto drag
-
Drag
Objectevent object
setRealScrollOffset
-
Object
Restores the top scrolled item according to the saved position.
Parameters:
-
Object
ObjectPreviously saved scroll position (by getRealScrollOffset method)
setStatus
()
Object
Set status text. Can be simple string or object with data formatted later in formatStatus method.
Returns:
String message or object with detailed data
storePersistentStates
()
Stores persistent (class) states for the control class and all subcontrols, this stores global (class) state (is same for all instances of the control)
storeState
()
Object
Stores state of the control and all its subcontrols having data-id specified.
Returns:
hierarchical object including states of the control and the subcontrols
thenWithProgress
-
pPromise
-
[params]
Method for handling Promise with delayed progress.
Parameters:
-
pPromise
PromisePassed promise
-
[params]
Object optionalObject with possible parameters:
- thenFunc - function called after resolving promise
- errorFunc - function called after rejecting promise
- delayedFunc - function called after given delay
- delayMS - progress delay, default 100ms. Progress is displayed after this time, in case promise was not resolved yet
- progressText - text displayed in delayed progress, default string is "Getting data"
- progress - SimpleTasksController object, used for progress. If not present, use global progress.
Properties
contextMenu
Menu
Gets/sets context menu of the control. It could be also a function returning Menu object.
dataSource
Object
Gets/sets the datasource which is/will be shown
disabled
Bool
Gets/sets data-disabled attribute of the control and his childs
dockable
Boolean
Gets/sets dockable status of the control.
dockMenuItems
Menu
Gets/sets dock menu of the control. It could be also a function returning Menu object.
dockTitle
String
Gets/sets dock title.
focusedIndex
Integer
Gets/sets index of the focused item. In case there's a datasource, its focusedIndex property is modified.
focusedItem
Object
Gets the focused item/object according to the current focusedIndex
headerTitle
String
Header title to be shown (in case 'showHeader' property is set).
isDock
Boolean
Gets/sets isDock status of the control.
isSearchable
Boolean
Get/set whether this control is searchable (e.g. via search bar)
minWidth
Number
Gets/sets min-width of the control, in pixels.
parentView
Object
Gets/sets view data.
showHeader
Boolean
Whether to show header.
statusParams
Object
Gets/sets params for statusbar.
tabIndex
Integer
Gets/sets tabIndex property. Use instead of tabIndex in HTMLElement for correct handling of disabled state.
visible
Boolean
Gets/sets visibility state of the control.