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

Undefined in Results yet TextField and ValueField are correct.

3 Answers 69 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 Jul 2018, 09:24 PM

Hi, I'm struggling with something that should be easy, so I hope you can point to something stupid I'm doing wrong.

I have this MultiSelectFor.  When I go the GetCertifications method, I am returning the expected number of results, yet the display shows undefined for each one.  I'd expect that to happen if the fields were misnamed, but as far as I can tell I'm getting them correctly with the appropriate names.

 

@(Html.Kendo().MultiSelectFor(m => m.CertificationList)
                      .DataTextField("CertTitle")
                      .DataValueField("Id")
                      .Placeholder("Select Certifications...")
                      .AutoBind(false)
                      .MinLength(3)
                      .Filter(FilterType.Contains)
                      .DataSource(source =>
                      {
                          source.Read(read =>
                          {
                              read.Action("GetCertifications", "DemandForecastInfoSummary");
 
                          })
 
                      .ServerFiltering(true);
                      })
                  )

 

public ActionResult GetCertifications(string text)
      {
          if (string.IsNullOrEmpty(text))
          {
              return Json("", JsonRequestBehavior.AllowGet);
          }
          var rtnValue = new SelectList( DemandPlanService.GetAllCertifications(text).ToList(),"Id","CertTitle");
            
          return Json(rtnValue, JsonRequestBehavior.AllowGet);
      }

 

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 30 Jul 2018, 10:54 AM
Hello Michael,

The implementation in the demonstrated code seems correct and it looks like that the only possibility is if the fields are mistyped. You can doublecheck the names in the Network tab of your browser console, by exploring the JSON result from your controller. Please refer to this screenshot, where this is demonstrated.

Regards,
Nencho
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
Michael
Top achievements
Rank 1
answered on 30 Jul 2018, 12:01 PM

Thanks Nencho, I was able to solve this myself, by simply not using a SelectList.  Instead I just return a Generic List of my objects but only populated each new object with the values I really needed (Id and CertTitle).  I'm not sure I understand WHY this fixed the issue, but I honestly spent way more time on the issue than I budgeted for, so I had to just be happy it worked and moved on.

 

Mike

0
Nencho
Telerik team
answered on 01 Aug 2018, 10:43 AM
Hello Michael,

I am happy to see that the experienced issue is now fixed. As for the issue itself - it is probably related with an uppercase for the first character of the fields. That was the reason why I suggested to inspect the request and the data in order to doublecheck the name of the fields.

Regards,
Nencho
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
Michael
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Michael
Top achievements
Rank 1
Share this question
or