You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to force the list of nodes to only have one "isChecked" node by calling a function that would update the data from the onCheckToggleCb but to no avail.
here is the code:
<SuperTreeview
....
onCheckToggleCb={(arrayOfNodes, depth)=>{ this.handleCheck(arrayOfNodes);
....
/>
handleCheck(arrayOfNodes) {
const isChecked = arrayOfNodes[0].isChecked;
const nodeId = arrayOfNodes[0].id;
var data = this.state.data;
// if the node is being unchecked, leave data alone (it will update itself)
if (isChecked) {
// if the node is being checked, "wipe out" all the "checked" node in this.state.data (should be only one)
applyCheckStateTo(data, nodeId);
// Set the updated data in this.state.data
this.setState({data: data});
}
function applyCheckStateTo(data, nodeId){
data.forEach((node)=>{
if (node.id != nodeId)
node.isChecked = false;
else
node.isChecked = true;
if(node.children){
applyCheckStateTo(node.children, nodeId);
}
})
}
}
Previous response suggested that is any properties need to be modified, it can be done on the onUpdateCb function, but how do I know (from onUpdateCb) which node to leave check and which node to uncheck as "arrayOfNodes is Not pass to onUpdateCb.
Appreciate any help
The text was updated successfully, but these errors were encountered:
I try to force the list of nodes to only have one "isChecked" node by calling a function that would update the data from the onCheckToggleCb but to no avail.
here is the code:
<SuperTreeview
....
onCheckToggleCb={(arrayOfNodes, depth)=>{
this.handleCheck(arrayOfNodes);
....
/>
Previous response suggested that is any properties need to be modified, it can be done on the onUpdateCb function, but how do I know (from onUpdateCb) which node to leave check and which node to uncheck as "arrayOfNodes is Not pass to onUpdateCb.
Appreciate any help
The text was updated successfully, but these errors were encountered: