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

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

3 Answers 139 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 26 Jul 2019, 03:45 PM

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" } })
)

3 Answers, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 30 Jul 2019, 03:17 PM
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.
0
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 31 Jul 2019, 01:37 PM
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"
0
Petar
Telerik team
answered on 02 Aug 2019, 09:12 AM
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.
Tags
MultiSelect
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Petar
Telerik team
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or