# Value Binding

The value of the MultiColumnComboBox can either be a [primitive (strings, numbers, or other)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values) or a [complex value (objects)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Objects).

To set the value, apply any of the following approaches:

* Use the [`value`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#value) property. If the value is set through the [`value`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#value) property, you have to hook up to the [`valueChange`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#valuechange) event and manually update the value of the [`value`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#value) property.
* Use the [`ngModel`](https://angular.dev/guide/forms) value binding. If the value is set by the [`ngModel`](https://angular.dev/guide/forms) value binding, the framework will automatically update the corresponding field from the model after the value of the component changes.
* Use the [`formControlName`](https://angular.dev/api/forms/FormControlName) value binding, which is available in the [Reactive forms](https://angular.dev/guide/forms/reactive-forms). If the value is set by the [`formControlName`](https://angular.dev/api/forms/FormControlName) value binding, the framework will automatically update the corresponding field from the form model after the value of the component changes.

> - The MultiColumnComboBox does not support the simultaneous usage of the [`value`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#value) property and the [`ngModel`](https://angular.dev/guide/forms) value binding.
> - The MultiColumnComboBox does not support values, which contain `\n` new line characters. The regular `input` HTML DOM element, which the MultiColumnComboBox uses internally treats `\n` as a regular whitespace. Therefore, when the component compares the value of the `input` element with the data item that is selected by the user, the two values differ. The value of the `input` element is actually not present in the data of the component and the MultiColumnComboBox does not recognize it. To handle such issues, map the incoming data so that it contains regular whitespaces only.

When binding the MultiColumnComboBox value, the component provides options for:

* [Using primitive values (strings, numbers, or other)](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/value-binding#primitive-values)
* [Using complex values (objects)](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/value-binding#object-values)
* [Handling invalid value errors](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/value-binding#invalid-value-errors)
* [Handling unresolved text input](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/value-binding#handling-unresolved-text-input)

## Primitive Values

To extract and use as a component value only the [`valueField`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#valuefield) value of the provided objects, set the [`valuePrimitive`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#valueprimitive) property of the MultiColumnComboBox to `true`.

The following example demonstrates how to use as a component value the `id` field value of the provided objects.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/dropdowns/multicolumncombobox/value-binding/primitive-value/source.txt)

## Object Values

The MultiColumnComboBox can only be data-bound to object values and, therefore, will expect to be bound to an object value by default.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/dropdowns/multicolumncombobox/value-binding/object-value/source.txt)

## Invalid Value Errors

If the value, which is assigned through the `[value]` or `[(ngModel)]` inputs, does not match the expected type, the MultiColumnComboBox will throw a JavaScript error.

In the following example, the [`valuePrimitive`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#valueprimitive) is not set to `true`, so the MultiColumnComboBox expects an object value. Instead, the example provides a number and, as a result, a JavaScript error is thrown in the console.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/dropdowns/multicolumncombobox/value-binding/invalid-value/source.txt)

To fix the JavaScript issue, either:

* Provide the complete object as value, or
* Set the [`valuePrimitive`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#valueprimitive) property to `true`.

The following table lists the valid configuration scenarios.

| \[value]  | \[data] | \[valuePrimitive]                             |
| :-------- | :------ | :-------------------------------------------- |
| object    | objects | Not set (automatically calculated as `false`) |
| primitive | objects | `true`  (manually set by the developer)       |

## Handling Unresolved Text Input

The text value which is assigned through the `[value]` or `[(ngModel)]` inputs and which is not found in the dataset will not be resolved. Such values also include object values that contain the [`textField`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#textfield) property when [`allowCustom`](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent#allowcustom) is set to `false`.

The following example demonstrates how to merge the assigned value with the dataset and ensure that its text will be properly extracted and displayed.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/dropdowns/multicolumncombobox/value-binding/resolve-text/source.txt)

## Suggested Links

* [API Reference of the MultiColumnComboBox](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/api/multicolumncomboboxcomponent)
* [Data Binding](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/data-binding)
* [Columns](https://www.telerik.com/kendo-angular-ui-develop/components/dropdowns/multicolumncombobox/columns)
