TreeView
The TreeView control enables you to display complex dataSources/catalogs in a hierarchical view and offers the possibility to select and store multiple values as well as the hierarchical path of the values.
The catalogs must be valid and compatible JSON represenations.
If you develop locally in the FormDev environment it´s best to paste the full catalog URL including the "hierarchy" part (eg. https://exampleserver.hybridforms.net/api/catalog/TreeviewCatalog/hierarchy) in your browser and add the resulting JSON response as local file to your formDefinition folder.
<div id="treeview_minimum"
data-win-control="HFWinJSCtrl.TreeView"
data-win-options="{
label: 'TreeView',
url: '/api/catalog/Hierarchietest/hierarchy',
treeviewCtrlOptions: {
dataTextField: 'Text',
dataValueField: 'ID',
},
selectCtrlOptions:{
placeholder: 'Open tree',
}
}"></div>
<div id="treeview_complex"
data-win-control="HFWinJSCtrl.TreeView"
data-win-options="{
label: 'TreeView',
multiselect: true,
url: '/api/catalog/Hierarchietest/hierarchy?start=0001&maxlevel=3&sort=Text&select=Text,ID',
treeviewCtrlOptions: {
checkboxes: {
checkChildren: true
},
dataTextField: 'Text',
dataValueField: 'ID',
selectOnlyLeaves: true,
},
textValueCallback: HFFormdefinition.QAFormHelpers.getTreeViewTextTemplate,
selectCtrlOptions:{
placeholder: 'Open tree',
},
onChanged: HFFormdefinition.QAFormHelpers.onTreeViewChange
}"></div>
The TreeView control currently supports only a via URL provided datasource.
FormControl Options
Options of the kendo components are also available. (TreeView, MultiSelect) read more
url - required
The URL must be a HFSql server relative URL. For instance, the oData link to a HFSql server list. Note: The url has to contain '/hierarchy' to obtain the hierarchical catalog. Possible URL paramters are:
- start: Define the start node inside the catalog to reduce the provided items.
- maxlevel: Define the nodes depth (levels) of the presented catalog to reduce the provided items for example show only items of the first three levels.
- sort: Define a sort criterion according to which the items are sorted in ascending order. These sort values are used to build up the "sortpath".
- select: Define the columns to be included in the query. Not defined the complete catalogs is queried.
url: '/api/catalog/Hierarchietest/hierarchy?start=0001'
string
doNotCopy
Set "true" whenever the field should get deleted if form is copied.
doNotCopy: true
boolean
list
Set this property to "true" if data connected with this control should be a sorting/filtering/grouping option on the listpage, is used in template objects (eg. the listTemplate) or it should show up in admin ui listings.
list: true
boolean
listOptions
Set additional options for controls with list equals true. E.g. set custom label for filter/sort/group dialogs or hide them complettely.
listOptions: {...}
{ dialogText: string, dialogHide: boolean }
multiselect
Set "true" whenever the user can select more than one value.
multiselect: true
boolean
onChanged
Call a pre-defined JS-method to do something when the status of the control changes.
onChanged: HFFormdefinition.Namespace.Method
function
function(value: { id: string, text: string }[]) => void
selectCtrlOptions: {placeholder: '...'}
Define a placeholder value - this option is obligatory.
selectCtrlOptions: {placeholder: 'Open tree'}
MultiSelectOptions
textValueCallback
Provide a method to configure the text value, for example show the complete path of the selected item (node).
textValueCallback: NameSpace.getTreeViewTextTemplate
function
function(nodeVal: string, node: any) => string
treeviewCtrlOptions
This array contains the options to configure the selection behaviuor of the node and its children. Default setting is no simultaneous selection of children.
treeviewCtrlOptions: { ... }
TreeViewOptions
treeviewCtrlOptions: {checkboxes: {..}}
Set the option checkChildren to true, if you want to select all the children of a node simultaneously.
checkboxes: { checkChildren: true } }
TreeViewOptions
treeviewCtrlOptions: {dataTextField: 'Text'}
Provide the catalog column name of the text value of the items.
dataTextField: 'Text'
TreeViewOptions
treeviewCtrlOptions: {dataValueField: 'ID'}
Provide the catalog column name of the unique identifier (i.e.: ID or Title) of the items.
dataValueField: 'ID'
TreeViewOptions
treeviewCtrlOptions: {selectOnlyLeaves: true}
Set the option to true to restrict the selection to the "leaves" (i.e. the end nodes of the tree). Default setting is false.
selectOnlyLeaves: true
TreeViewOptions
listOptions Object
dialogText
Set custom label for filter/sort/group dialogs.
dialogText: 'Display Text'
string
Stored data
For each TreeView inside your forms there are two value pairs of stored data:
First the information for the TreeView itself
{
"id": "treeview",
"value": "0009"
}
and second for the selected value:
{
"id": "treeview_HFText",
"value": "Punkt 3"
}