New to KendoReact? Start a free 30-day trial
handleTreeViewCheckChange
A helper function which updates the check descriptor.
jsx
class App extends React.Component {
state = { check: [], items: tree };
render() {
return (
<div>
<TreeView
checkboxes={true} onCheckChange={this.onCheckChange}
data={processTreeViewItems(this.state.items, { check: this.state.check })}
/>
<div style={{ marginTop: 5 }}>
<i>Press SPACE to check/uncheck the active item</i>
<div className="example-config">
Checked Indices: {this.state.check.join(",")}
</div>
</div>
</div>
);
}
onCheckChange = (event) => {
this.setState({ check: handleTreeViewCheckChange(event, this.state.check, this.state.items) });
}
}
const tree = [ {
text: 'Furniture', expanded: true, items: [
{ text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' } ]
}, {
text: 'Decor', expanded: true, items: [
{ text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' } ]
} ];
ReactDOM.render(<App />, document.querySelector('my-app'));
Parameters
event
The event that triggered the change.
check
string[] | TreeViewCheckDescriptor
The check descriptor that will be updated.
data?
"null" | any[]
The TreeView items.
settings
The additional settings that configure the update of the check descriptor.
childrenField?
string
The field that points to the dataItem sub items. Defaults to `items`.
The default behavior allows the selection of multiple items.
Returns
any[] | TreeViewCheckDescriptor intersected with { ids: any[]; }
- The updated copy of the input check descriptor.