Failed to populate existing value to Kendo UI MultiSelect control in MVC project

4 posts, 1 answers
  1. Daochuen
    Daochuen avatar
    63 posts
    Member since:
    Sep 2017

    Posted 26 Jul 2019 Link to this post

    Hello all,
    I used Kendo UI MultiSelect and Grid  controls in my MVC project. There is one column called "Actions" with string value ( like "Read" or "Read, Create" or ...) on  the Grid. When  user click "Edit" command, Kendo MultiSelect control ( It located inside sub folder "EditorTemplates") will appear one that column to let user re-select the actions.  The code worked file except failed to populate current values  of the "Actions", I tred couples of way but no lucky so far. Can I get someone's Help?

    Thanks in advance!

     

    Below are pieces of code:

    One of Grid columns:
    columns.Bound(p => p.Actions).Width(200).Title("Actions").EditorTemplateName("Actions");

    Multiple selection Control in "Actions.cshtml" view which inside "EditorTemplates" folder

    @(
        Html.Kendo().MultiSelectFor(m => m)
            .Name("Actions")
            .DataTextField("Text")
            .DataValueField("Value")
            .AutoClose(false)
            .ClearButton(false)
            .BindTo(new List<SelectListItem>() {
                                  new SelectListItem() {Text = "Create", Value = "1" },
                                  new SelectListItem() {Text = "Read", Value = "2" },
                                  new SelectListItem() {Text = "Update", Value = "3" },
                                  new SelectListItem() {Text = "Delete", Value = "4" } })
    )

  2. Answer
    Petar
    Admin
    Petar avatar
    367 posts

    Posted 30 Jul 2019 Link to this post

    Hi Daochuen,

    Thank you for the detailed information and the code snippet. Based on the provided information I cannot be absolutely sure what is triggering the reported behavior. The configuration seems to be OK and this is why I would like to ask you for a runnable project where the issue could be reproduced.  

    Some things you could try before send me a project are:
    • As the partialView uses MultiSelectFor the .Name() configuration of the MultiSelectFor is not needed, so you can remove it. 
    • Try moving the Actions.cshtml in the Shared folder of your project, not in EditorTemplates.

    If none of the above resolve the issue, please isolate it in a runnable project and send the project back to me, so we could further investigate what is triggering the reported behavior.
    Looking forward to your reply.

    Regards,
    Petar
    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.
  3. Daochuen
    Daochuen avatar
    63 posts
    Member since:
    Sep 2017

    Posted 31 Jul 2019 in reply to Petar Link to this post

    Hi Petar,

    Thanks respond! I resolved issue by adding ID array to Kendo MultiSelet control's Value in Grid Edit event. The code like below:

                var arr = [];
               ...
               ...
                var actionsCtr = $("#Actions").data("kendoMultiSelect");
                actionsCtr.value(arr); //arr[0]="1", arr[1]="2" if Action column in grid showed as "Create,Read"
  4. Petar
    Admin
    Petar avatar
    367 posts

    Posted 02 Aug 2019 Link to this post

    Hi Daochuen,

    I'm happy you've managed to resolve the issue! If you need further assistance, please let me know. 

    Regards,
    Petar
    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.
Back to Top