Programmatically set values when binding to entire objects

8 posts, 1 answers
  1. Matt
    Matt avatar
    4 posts
    Member since:
    Feb 2008

    Posted 30 Dec 2016 Link to this post

    If primitive binding is disabled (e.g. not using k-data-value-field), I cannot set the value of the drop down programmatically. For example: http://dojo.telerik.com/aZUXi

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2594 posts

    Posted 02 Jan Link to this post

    Hello,

    In order to set a value to the MultiSelect widget when complex data is used, you need to provide a valid dataValueField configuration, this way the widget will know how to match the value set via the value() method and the corresponding dataItem of the dataSource.

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Matt
    Matt avatar
    4 posts
    Member since:
    Feb 2008

    Posted 03 Jan Link to this post

    What dataValueField configuration if I want to bind to the entire this object? I would like the .value() method to return the entire dataItem since I need multiple values from it.
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2594 posts

    Posted 04 Jan Link to this post

    Hello,

    The valueField should be set to a field of your data. See the updated sample:

    http://dojo.telerik.com/aZUXi/3

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Matt
    Matt avatar
    4 posts
    Member since:
    Feb 2008

    Posted 04 Jan Link to this post

    If I set the data value field I do not get the data I need.

    I created a new example, much closer to what I am doing. http://dojo.telerik.com/agATe

    If you visit that link and add The Dark Night to the list, a warning will pop up. I'd also like the user to add custom items to that multi select but if they are added then the warning will also popup. This is almost working - if you type a movie not in the list ('test') then you will see the custom no data template. Clicking the button does add the item to the data source but does not select it. The user has to open the multi select again, select the new custom item again, and then it will persist and the warning message show.

    Thank you.
  6. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2594 posts

    Posted 05 Jan Link to this post

    Hello,

    You need to add the item to the source first. See his:

    http://dojo.telerik.com/agATe/5

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Matt
    Matt avatar
    4 posts
    Member since:
    Feb 2008

    Posted 05 Jan Link to this post

    That worked! To recap, the order was important (push to the data source collection, update the data source with the multiselect, then push to the selected values collection), and the dataValueField was required like you mentioned, and obviously valuePrimitive remains false.
  8. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2594 posts

    Posted 05 Jan Link to this post

    Hello,

    Happy to help.

    In case you have any further questions - do not hesitate to contact us.

    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top