# Updating Selected Items

The TreeView provides specific approaches for working with its data and updating the `selected` field.

The available options are:

* [Mutating the items directly](https://www.telerik.com/kendo-vue-ui/components/treeview/selection/update-selected-items#mutating-the-items-directly)
* [Using a helper function](https://www.telerik.com/kendo-vue-ui/components/treeview/selection/update-selected-items#using-a-helper-function)

## Mutating the Items Directly

The following example demonstrates how to directly update the selected items in a TreeView with single selection.

[Demo Source](https://demos.telerik.com/kendo-vue-ui/treeview/select/selection-update/source.txt)

## Using a Helper Function

The [`processTreeViewItems`](https://www.telerik.com/kendo-vue-ui/components/treeview/api/processtreeviewitems) helper function updates the items in an immutable way, that is, works with a copy of the data. While using `processTreeViewItems` is similar to creating a copy of the data before each item update, the `data` field of the application state does not change. That is why, the helper function approach is useful when other components depend on the `data` field.

The following example demonstrates how to introduce an additional state field (`select`) which holds the IDs of the selected items and is passed to [`processTreeViewItems`](https://www.telerik.com/kendo-vue-ui/components/treeview/api/processtreeviewitems) on each re-render.

[Demo Source](https://demos.telerik.com/kendo-vue-ui/treeview/select/selection-update-helper-function/source.txt)

## Suggested Links

* [`onItemClick`](https://www.telerik.com/kendo-vue-ui/components/treeview/api/treeviewitemclickevent)
* [`processTreeViewItems`](https://www.telerik.com/kendo-vue-ui/components/treeview/api/processtreeviewitems)
* [`onExpandChange`](https://www.telerik.com/kendo-vue-ui/components/treeview/api/treeviewexpandchangeevent)
* [API Reference of the TreeView](https://www.telerik.com/kendo-vue-ui/components/treeview/api/treeviewprops)
