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

Programatically set Listbox value

4 Answers 1404 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 14 Mar 2019, 06:54 PM

I have a Kendo ListBox that I need to set a single item selected through a JavaScript function. I know both the text and value that I want to set, but can't figure out how. Any help appreciated!

Steve.

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 15 Mar 2019, 02:53 PM
Hello Steve,

You can use the add method to achieve this requirement. You can find a live sample demonstrating that here:
https://demos.telerik.com/kendo-ui/listbox/api

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Steve
Top achievements
Rank 1
answered on 15 Mar 2019, 03:12 PM
Sorry, that's not quite it. I have an existing list with, say, 5 items in it and I want to select item #2. More specifically, I want to select the one with the value of 2. 
0
Eyup
Telerik team
answered on 18 Mar 2019, 09:29 AM
Hi Steve,

You can use the select method in this case:
https://docs.telerik.com/kendo-ui/api/javascript/ui/listbox/methods/select

I've also provided a live dojo sample for demonstration:
https://dojo.telerik.com/IjISeBic/6

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Steve
Top achievements
Rank 1
answered on 18 Mar 2019, 01:53 PM
Perfect! Thank you!!
Tags
ListBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Steve
Top achievements
Rank 1
Share this question
or