Last Updated on May 1, 2018 by Neil Murray
Edit handling is added in Visual.editOnChange(). RST component states can be used:
- rowInfo.node – current edited node
- treeData – current treeData
Function Parameters
- event [object] Required, event.target contains:
– name
– value
– checked
– type - optionsArrayType [string] null, create array for rowInfo.node.
- index [string/integer] null, create object key for optionsArrayType.
- _rowInfo [object] null, passed row info from child components.
Main Scheme
- If
_rowInfois passed, update treeData directly. - Else, do input handling as described below.
Input Handling
Visual.editOnChange should handle input change properly with following rules:
- Check if provided key exists in rowInfo.node. If not, create empty array and push new value.
- Check for input type and function parameters:
- checkbox: rowInfo.node[name] = checked
- checkbox & optionsArrayType & index: rowInfo.node[optionsArrayType][index].isChecked = checked
- radio & optionsArrayType & index: rowInfo.node[optionsArrayType][index].isChecked = (bool)
- range, number: rowInfo.node[name] = parseInt(value,10)
- text, default: rowInfo.node[name] = value
- Deleting/removing all items from array or object should result empty [ ] or { }.
- Update treeData and rowInfo
Further reading: Edit Input Handling (BitBucket Issue)