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

MultiSelect will slect all in the box after first selection

3 Answers 70 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Allen
Top achievements
Rank 1
Veteran
Allen asked on 17 Mar 2021, 08:06 PM

Is there anyone know why the MultiSelect works fine for the first item. After first one select, it will not work properly( please see the screen shot). type a letter then all matched item will be selected. Click any one then the box will reset.

cshtml

      @(Html.Kendo().MultiSelect()
              .Name("Users")
              .DataTextField("FullUserInfo")
              .DataValueField("UserID")
              .Placeholder("Type Last Name or First Name")   
              .DataSource(source => {
                  source.Read(read =>
                  {
                      read.Action("GetFilterUser", "Method");
                  })
                  .ServerFiltering(true);
                })
            )

 

Controller

        [HttpGet]
        public JsonResult GetFilterUser(string text)
        {
           
            personList = (IEnumerable<UserListboxDataViewModel>)
                       dataService.GetAllPersonsforListBox();

            if (!string.IsNullOrEmpty(text))
            {
                personList = personList.Where(p =>
                    (p.FullUserInfo.Contains(text))).ToList();
            }

            return Json(personList, JsonRequestBehavior.AllowGet);
        }

3 Answers, 1 is accepted

Sort by
0
Allen
Top achievements
Rank 1
Veteran
answered on 18 Mar 2021, 06:45 PM

I also have javascript below. If I comment out, this part, the multiselect box won't show anymore.

             <script>
               function onAdditionalData() {
                    return {
                        text: $("#Users").val()
                    };
                } 
            </script>

0
Martin
Telerik team
answered on 22 Mar 2021, 12:42 PM

Hello, Allen,

I tested the provided code snippets in the attached project and they seem to behave as expected. Could you please modify the example so that I can observe the problem you are experiencing? I will then be happy to debug and see what is causing the problem.

Looking forward to your reply.

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Allen
Top achievements
Rank 1
Veteran
answered on 23 Mar 2021, 01:10 PM

Thanks Martin,
I fixed it. the reason that I got unexpected result is  the parameter in  DatavalueField('UserID") statement  is not right. After I replace "UserID" with "UserId", it works fine.

 

Tags
MultiSelect
Asked by
Allen
Top achievements
Rank 1
Veteran
Answers by
Allen
Top achievements
Rank 1
Veteran
Martin
Telerik team
Share this question
or