Getting Started with KendoReact TreeView

The KendoReact TreeView displays hierarchical data in a traditional tree structure, supports user interaction through mouse or touch events, and performs reordering operations by using the drag-and-drop functionality.

The KendoReact TreeView component is part of the KendoReact library of React UI components. It is distributed through NPM under the kendo-react-treeview package.

Basic Usage

The following example demonstrates the TreeView in action.

const tree = [{
    text: 'Furniture', expanded: true, items: [
        { text: 'Tables & Chairs' }, { text: 'Sofas' }, { text: 'Occasional Furniture' }]
}, {
    text: 'Decor', items: [
        { text: 'Bed Linen' }, { text: 'Curtains & Blinds' }, { text: 'Carpets' }]
}];

class App extends React.Component {
    render() {
        return (
            <TreeView
                data={tree}
                expandIcons={true}
                onExpandChange={this.onExpandChange}
                onItemClick={this.onItemClick}
                aria-multiselectable={true}
            />
        );
    }
    onItemClick = (event) => {
        event.item.selected = !event.item.selected;
        this.forceUpdate();
    }
    onExpandChange = (event) => {
        event.item.expanded = !event.item.expanded;
        this.forceUpdate();
    }
}

ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

Functionality and Features

Installation

  1. Download and install the package. Use Node.js v5.0.0 or later.

    npm install --save @progress/kendo-react-treeview @progress/kendo-react-animation
  2. Once installed, import the package module.

    // ES2015 module syntax
    import { TreeView } from '@progress/kendo-react-treeview';
    // CommonJS format
    const { TreeView } = require('@progress/kendo-react-treeview');
  3. You are required to install one of the Kendo UI themes to style your components. For more information on how to add the styles, refer to the article on getting started.

Dependencies

The TreeView package requires you to install the following peer dependencies in your application:

  • react
  • react-dom
  • @progress/kendo-react-animation
 /