I have like 17 grids on templates that display and service the CMS portion of a site. Until I noticed today, all grids were functioning fine for display and crud operations. Now the grids do not show the data.
I can put a breakpoint at the end of the read function and see that the data is there.
IQueryable<
Product
> res = viewModel.Products.AsQueryable<
Product
>();
DataSourceResult data = res.ToDataSourceResult(request);
JsonResult result = Json(data);
return Json(data);
So as the Read functions exit they have their data but the grids do not display anything! I have been working in an entirely different area on the retail part of the site over the last few days that has nothing to do with Telerik and have not changed any of the code on that controller or associated views that have to do with the CMS portion. I am completely stumped on this one
Any suggestions would greatly help. This is an important issue that has the CMS side of the site down.
Thanks
8 Answers, 1 is accepted
I discovered the problem. First of all this application is an ASP.NET MVC Core application and initializes the application and container in the Startup.cs. In the service configuration section I altered something in trying to resolve a serialization/deserialization issue. After adding back the DefaultContractResolver in the option settings for JSON the data returned to the display.
services.AddMvc()
// Maintain property names during serialization.
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
The most likely cause of the behavior you are seeing is the way data is serialized by .NET Core. By default the fields will be serialized in camelCase and the Grid component will usually expect them to be in PascalCase. In order to avoid this it is recommended to change the serialization settings.
Please check out step 5 in the article below that shows how you can configure the option.
Regards,
Viktor Tachev
Progress Telerik
Dear Viktor,
Is your answer (and the link) still valid (as of 2 Jan 2020)?
The link (step 5) mention about "Add the Kendo UI services to the services container".
I have done that but it still not working.
I have confirmed that json data has been passed, but kendo grid didn't show it.
i.e: json: id: "f9238530-712c-43c8-b1a7-0c0887f7743d" but my column: columns.Bound(p => p.Id);
I am using net core 3.1
Thanks in advance.
Sorry, found the answer:
https://www.telerik.com/forums/inline-grid-not-showing-records
https://docs.telerik.com/kendo-ui/knowledge-base/grid-is-not-showing-data
public void ConfigureServices(IServiceCollection services){...// Maintain property names during serialization. See:// https://github.com/aspnet/Announcements/issues/194 services .AddMvc().AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());// Add Kendo UI services to the services container services.AddKendo();}
Hello,
The structure of the linked article was changed a bit. The relevant information is available in the JSON Serialization section linked below:
Regards,
Viktor Tachev
Progress Telerik
Hello Victor.
I have added contract resolver which didn't help
I can see details in the response with the correct case
My grid is so simple:
@(Html.Kendo().Grid<AppUserModel1>()
.Name("grid_users1")
.Height(200)
.Columns(columns =>
{
columns.Bound(m => m.Email);
})
.DataSource(ds => ds
.Ajax()
.Model(m =>
{
m.Id(u => u.Id);
m.Field(u => u.Email).Editable(false);
})
.Read(r => r.Action("Get", "User").Type(HttpVerbs.Get))
.Update(u => u.Action("Put", "User").Type(HttpVerbs.Put))
)
.Deferred())