# Checking All Items

While the TreeView does not provide a built-in feature for checking and unchecking all its items at once, the component supports such an implementation.

To enable the check-all mode for its items, set the `checked` field of each TreeView node to `true`. To enable the uncheck-all mode for its items, set the `checked` field of each TreeView node to a falsy value. You can further handle the checking and unchecking of all items depending on whether you [update the items directly](https://www.telerik.com/kendo-react-ui-develop/components/treeview/checkboxes/check-all#updating-items-directly) or [use the helper functions](https://www.telerik.com/kendo-react-ui-develop/components/treeview/checkboxes/check-all#using-helper-functions).

## Updating Items Directly

The following example demonstrates how to directly update the `checked` field of all TreeView items.

[Demo Source](https://demos.telerik.com/kendo-react-ui/treeview/checkbox-all/func/source.txt)

## Using Helper Functions

The following example demonstrates how to use the [`handleTreeViewCheckChange`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/handletreeviewcheckchange) and [`processTreeViewItems`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/processtreeviewitems) helper functions to prepare the [`data`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewprops#data) of the TreeView and how to manually set the [`check`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewoperationdescriptors#check) descriptor to:

* All hierarchical item indices upon checking all items.
* An empty array upon unchecking all items.

```jsx
import React, { useState } from 'react';
import { TreeView } from '@progress/kendo-react-treeview';
import { processTreeViewItems, handleTreeViewCheckChange } from '@progress/kendo-react-treeview';

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' }]
    }
];

const App = () => {
    const [data] = useState(tree);
    const [check, setCheck] = useState([]);

    const checkAll = () => {
        // The hierarchical index of every item in the tree.
        setCheck(['0', '0_0', '0_1', '0_2', '1', '1_0', '1_1', '1_2']);
    };

    const uncheckAll = () => {
        setCheck([]);
    };

    const onCheckChange = (event) => {
        setCheck(handleTreeViewCheckChange(event, check, data));
    };

    return (
        <div>
            <div className="example-config">
                <Button onClick={checkAll}>Check all</Button>
                <Button onClick={uncheckAll}>Uncheck all</Button>
            </div>
            <TreeView
                data={processTreeViewItems(data, { check: check })}
                checkboxes={true}
                onCheckChange={onCheckChange}
            />
        </div>
    );
};

export default App;
```

## Suggested Links

* [`handleTreeViewCheckChange`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/handletreeviewcheckchange)
* [`TreeViewCheckChangeSettings`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewcheckchangesettings)
* [`processTreeViewItems`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/processtreeviewitems)
* [`TreeViewCheckDescriptor`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewcheckdescriptor)
* [`onCheckChange`](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewcheckchangeevent)
* [React TreeView Overview](https://www.telerik.com/kendo-react-ui-develop/components/treeview#react-treeview-overview)
* [API Reference of the TreeView](https://www.telerik.com/kendo-react-ui-develop/components/treeview/api/treeviewprops)
