How to Set values in kendo multiSelect

1 Answer 10403 Views
Sample Applications
This question is locked. New answers and comments are not allowed.
Suk
Top achievements
Rank 1
Suk asked on 14 Mar 2015, 10:05 AM
I am new to kendo and I recently started coding in C#.net MVC. I have a JSON array in jsonObj(variable name), like for example:

'[{"key":"Name","comparison":"Equals","values":["JOHN","LILY"]}]'

Now, I want this jsonObj.values to be set into the kendo multiSelect on a button click. I can see the values in alert as JOHN,LILY .

I coded:

$("#DrugNames").data("kendoMultiSelect").value(jsonObj.values);
$("#DrugNames").data("kendoMultiSelect").value(jsonObj.values.toString().split(','));

But, it doesn't seem to work... I also tried using:

$("#DrugNames").data("kendoMultiSelect").value(["JOHN","LILY"]);

Still no success. Please help.

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 17 Mar 2015, 09:06 AM

Hello Sukanya,

The Kendo UI MultiSelect widget will accept an array of values for its value method. Please check the following sample and let me know if it helps:

http://dojo.telerik.com/UpoHA

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Suk
Top achievements
Rank 1
commented on 18 Mar 2015, 11:55 AM

Thank you Kiril for replying...

But this doesn't seem to work. As I am really new to all this stuff, I am a bit confused.
'[{"key":"Name","comparison":"Equals","values":["JOHN","LILY"]}]' is a string which comes from my DB. So, I changed it back to JSON array using $.parseJSON.
The kendo multiselect is in a Kendo Window.What I wanted is if I had "Name" in the "key" portion, then just pick the "values" part and place it in the multiSelect just like the way you said, 
multiselect.value(jsonObj.values); So, I guess I am not wrong about how to set the values in multiSelect. 

Am I doing anything wrong with the Json thing?? Sorry if I am being naive. Thanks in advance.
Kiril Nikolov
Telerik team
commented on 21 Mar 2015, 07:16 AM

Hello Sukanya,

Please check the following sample and let me know if it helps:

http://dojo.telerik.com/AYIfa

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Nana
Top achievements
Rank 1
commented on 18 May 2017, 11:30 AM

Hi,

I am also new to  and I am wondering if there is any way to re-add the selected items to the kendo multiselect (allow duplications)
I tried tp get the selected items and hack the of the but it works partially.
There is a field in the kendoMultiSelect called _visibleitems so I guess the selected items are there in the but they are just invisible, how can I make them visible?

Thanks,
Entisar
Ivan Danchev
Telerik team
commented on 23 May 2017, 07:39 AM

Hi Entisar,

Duplicating items in the MultiSelect is a topic that has been discussed on the forums. See Atanas' reply in this thread.

Regards,
Ivan Danchev
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.
entisar
Top achievements
Rank 1
commented on 25 May 2017, 04:03 PM

Hi Ivan,
I found that we can extend the kendo multiselect and create one that allows duplications, (see: http://jsfiddle.net/abhinavg/ds0qyohu/ )
I was just wondering if there is any explanation about the implementation (like what is the fn in MultiSelect.fn.init.call ? what does this line do that.currentTag(null); ?

Regards,
Entisar
Ivan Danchev
Telerik team
commented on 29 May 2017, 01:45 PM

Hi Entisar,

The Support Service provides guidance and assistance with the widgets built-in features and API. Source code explanation and guidance on extending the widgets, aiming at achieving custom behavior different from the way the widget works by design, is provided by our Professional Services team. If you are interested in their services let us know and we will put you in touch with them.

Regards,
Ivan Danchev
Progress Telerik
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
Sample Applications
Asked by
Suk
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or