This is a migrated thread and some comments may be shown as answers.

ComboBox throws error when dynamically binding the valueField and textField inputs

1 Answer 699 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 11 May 2020, 08:14 AM

Hello,

I am attempting to bind the ComboBox to an array of complex objects. For this, the "keyField" and "valueField" properties are required (valuePrimitive is set to true, in case that is relevant).

This works if I do not try to bind to those properties:

<kendo-combobox valueField="myField" textField="myTextField" ... ></kendo-combobox>

However, if I try to use one-way binding:

<kendo-combobox [valueField]="myFieldBinding" [textField]="myTextBinding" ...></kendo-combobox>

I get the following error:

"Expected textField and valueField options to be set. See http://www.telerik.com/kendo-angular-ui/components/dropdowns/combobox/#toc-bind-to-arrays-of-complex-data"

I am 100% sure that actual string values are being provided for "myFieldBinding" and "myTextBinding". Further, I tested it as follows as well:

<kendo-combobox [valueField]="'hardcodedStringValueField'" [textField]="'hardcodedStringTextField'" ...></kendo-combobox>

And I get the same error.

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 12 May 2020, 10:12 AM

Hi Mike,

Indeed, both the valueField and textField inputs can be bound to component fields holding the desired strings:

https://stackblitz.com/edit/angular-tjobuq-96qezh?file=app/app.component.ts

Binding hardcoded strings directly works too:

https://stackblitz.com/edit/angular-y6w2fx-ysjx5e?file=app/app.component.ts

The only requirement for the component to be working as expected, is the data items objects the component is data-bound to, to actually contain properties with the respective names, bound to the textField and valueField options.

I hope this helps and comparing the examples above to your implementation and applying the necessary adjustments will yield the desired result, but if the issue persists, please send us a similar isolated runnable project where the described problem can be observed, so we can inspect it further, determine what is causing it, and try to provide a solution that is best suitable to the specific use case. Thank you in advance.

Regards,
Dimiter Topalov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ComboBox
Asked by
Mike
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or