0
votes

I have a kendo multiselect in an mvc application.

                 @(Html.Kendo().MultiSelectFor(a => a.Roles)
                              .Value(Model.SelectedRoles)
                              .DataValueField("Id")
                              .DataTextField("RoleName")
                              .Placeholder("")
                              .HtmlAttributes(new { required = "" })
                              .DataSource(source =>
                              {
                                  source.Read(read => read.Action("GetRoles", "UserManagement"));
                              }))

It gets populated with the GetRoles method like so:

public List<RoleViewModel> GetRoles()
    {
        var roles = _context.Roles.AsNoTracking().ToList();
        var roleList = new List<RoleViewModel>();

        foreach(var role in roles)
        {
            roleList.Add(new RoleViewModel
            {
                Id = role.Id,
                RoleName = role.Name
            });
        }

        return roleList;
    }

Now I'm trying to disable certain items inside the list how would I go about to do that?

I was thinking if I could add maybe a bool ItemStatus in my RoleViewModel and set that status to true/false based on some conditions but I have no idea how I would go about and actually apply it to the multiselect so that said items with the ItemStatus set to false would be disabled.

1

1 Answers

0
votes

Try to find below mention code in reference link. Check this link
There are property of unselectableItem: true and unselectableItem: false which can help.