How to Set values in kendo multiSelect

4 posts, 0 answers
  1. Suk
    Suk avatar
    15 posts
    Member since:
    Mar 2015

    Posted 14 Mar 2015 Link to this post

    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.
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 17 Mar 2015 Link to this post

    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!
     
  3. Suk
    Suk avatar
    15 posts
    Member since:
    Mar 2015

    Posted 18 Mar 2015 in reply to Kiril Nikolov Link to this post

    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.
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 21 Mar 2015 Link to this post

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