ComboBox throws error when dynamically binding the valueField and textField inputs

2 posts, 0 answers
  1. Mike
    Mike avatar
    11 posts
    Member since:
    Oct 2008

    Posted 11 May Link to this post

    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.

  2. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1282 posts

    Posted 12 May Link to this post

    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.
Back to Top