# Updating Expanded Items

The Kendo UI for Vue TreeView provides specific approaches for working with its data and updating the `expanded` field.

The available options are:

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

## Mutating the Items Directly

The following example demonstrates how to directly update the TreeView items.

[Demo Source](https://demos.telerik.com/kendo-vue-ui/treeview/expand/items-expanded-directly/source.txt)

## Using a Helper Function

The [`processTreeViewItems`](https://www.telerik.com/kendo-vue-ui-develop/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 (`expand`) which holds the IDs of the expanded items and is passed to [`processTreeViewItems`](https://www.telerik.com/kendo-vue-ui-develop/components/treeview/api/processtreeviewitems) on each re-render.

[Demo Source](https://demos.telerik.com/kendo-vue-ui/treeview/expand/items-expanded-helper-function/source.txt)

### Using a Helper Function with Custom Data Items

When working with custom data items in a Helper function scenario, in addition to the default configuration, we have to define values for the [textField](https://www.telerik.com/kendo-vue-ui-develop/components/treeview/api/treeviewprops#textfield) and [childrenField](https://www.telerik.com/kendo-vue-ui-develop/components/treeview/api/treeviewprops#childrenfield) properties

[Demo Source](https://demos.telerik.com/kendo-vue-ui/treeview/expand/custom-items-expanded-helper-function/source.txt)

## Suggested Links

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