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

Programmatically set values when binding to entire objects

7 Answers 290 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 30 Dec 2016, 04:43 PM

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

7 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 02 Jan 2017, 07:45 AM
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.
0
Matt
Top achievements
Rank 1
answered on 03 Jan 2017, 02:40 PM
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.
0
Kiril Nikolov
Telerik team
answered on 04 Jan 2017, 08:51 AM
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.
0
Matt
Top achievements
Rank 1
answered on 04 Jan 2017, 09:43 PM

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.
0
Accepted
Kiril Nikolov
Telerik team
answered on 05 Jan 2017, 08:29 AM
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.
0
Matt
Top achievements
Rank 1
answered on 05 Jan 2017, 02:01 PM
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.
0
Kiril Nikolov
Telerik team
answered on 05 Jan 2017, 04:27 PM
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.
Tags
MultiSelect
Asked by
Matt
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Matt
Top achievements
Rank 1
Share this question
or