Cannot get Kendo DropDownList to display values, displays "undefined"

1 Answer 293 Views
DropDownList
Ross
Top achievements
Rank 1
Ross asked on 17 Jan 2023, 09:18 PM

Context: This is an ASP.NET Core 6 project using MVC controllers.  I have successfully gotten Grid widgets to work on another page which shares the same _Layout as the below page.  As a result, I think it's unlikely that my issue is related to how Kendo is installed in the project.

The Problem

I am attempting to add a searchable DropDownList to my project.  Though my ultimate goal is to use Virtualization to allow the search of a very large number of objects, I am unable to get the widget to function with a much small set of test data.  No matter how I attempt to configure the widget or change how I pass data back to it I get the same result:

 

I have confirmed via the Visual Studio debugger that my Json response contains the correct data and contains no values that are null or empty. 

 

My Code:

View

Note: SamAccountName is the field that should be displayed, used for text search, and selected as a value by the user.

Controller

Domain Model

As stated, the current code is much more simple than what I will eventually require, but I cannot even get this to work.  I have tried structuring the controller about a hundred different ways, and the only change is that sometimes I get an error saying a field can't be recognized.  Is this something to do with how I'm structuring my Json?  

I've been beating my head against this for almost 2 days now, I could really use some help.

 

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 20 Jan 2023, 04:06 PM

Hi Ross,

I noticed that this is a duplicate inquiry from a previously created private support thread. Regardless, I will share my answer here as well for the benefit of the community:

"The issue that you are facing may be caused by the JSON Serialization configuration that is used for the property name casing of data-bound components within the Telerik UI for ASP.NET Core suite. Having this in mind, if the serializer changes the casing to camelCase, but PascalCase is inspected instead, the component will not bind to the data, resulting in an unsuccessful attempt to display the fetched data."

"If this is the case, I would recommend setting the JSON Serialization to the initially added services within the integrated Program.cs file of the application".

Program.cs:

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews()
                // Maintain property names during serialization. See:
                // https://github.com/aspnet/Announcements/issues/194
                .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver());
// Add Kendo UI services to the services container"
builder.Services.AddKendo();
...

More in-depth information regarding this topic can be found here:

JSON Serialization

Kind Regards,
Alexander
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.

Tags
DropDownList
Asked by
Ross
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or