ASP.NET CORE and Kendo Grid

I have a lot of experience working with kendo grid in ASP MVC so I was definitely not expecting any surprises wiring up a simple grid with a remote data source in ASP.NET core. Well I was wrong 😛

Here is my view:

c1

 

And my controller action:

c2

 

In ASP MVC those two would have been enough. However in ASP.NET Core you need to take an additional step for the kendo grid to be able to read the data (see Startup.cs code below). This is because ASP.NET Core incorporated Newtonsoft’s JSON Serializer and for some reason decided to set the default behavior to change the casing of our properties to camelCase (using CamelCasePropertyNamesContractResolver). In order to force it to use the same property names that we defined in our view models we need to use the

c4

 

For more info about who is to blame for the brilliant decision of making camelCase the default take a look at:

https://github.com/aspnet/Mvc/issues/4283

https://github.com/aspnet/Mvc/issues/4842

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s