handleTreeViewCheckChange

A helper function which updates the check descriptor.

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 TreeViewExpandChangeEvent

The event that triggered the change.

check string[] | TreeViewCheckDescriptor

The check descriptor that will be updated.

data? any[] | null

The TreeView items.

settings TreeViewCheckChangeSettings

The additional settings that configure the update of the check descriptor. The default behavior allows the selection of multiple items.

Returns

any - The updated copy of the input check descriptor.

 /