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

Grid not displaying any records in .NET Core 3.1

4 Answers 913 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nick Gilbert
Top achievements
Rank 1
Nick Gilbert asked on 19 Mar 2020, 10:55 AM

I've ported my app from .NET Framework MVC to .NET Core 3.1.  The Kendo Grid displays OK and fetches data from the controller successfully (no javascript console errors). However despite the fact that 10 records are returned, the grid isn't actually rendering any rows.   What could I be doing wrong?

Controller:

public ActionResult FetchUsers([DataSourceRequest] DataSourceRequest request)
{
    var cardivationApi = GetCardivationApi();
    var data = cardivationApi.GetUsersFiltered(request);
    return new JsonResult(data);

}

 

View:

@(Html.Kendo().Grid<UserDtoV1>().Name("grid")
              .Columns(columns =>
              {
                  columns.Bound(p => p.FirstName).Title(DbRes.T("FirstName", "Labels"))
                      .Filterable(t => t.Cell(cell => cell.Operator("startswith").SuggestionOperator(FilterType.StartsWith).Delay(9999))
                          .Operators(o => o.ForString(d => d.Clear().StartsWith(DbRes.T("StartsWith", "Labels")).Contains(DbRes.T("Contains", "Labels"))))
                          .Extra(false));
                  [ cut for brevity ]
                     
                   
                .Pageable(p => p.PageSizes(true).PageSizes(new[] { 10, 20, 50, 100 }).Messages(t => t.ItemsPerPage(DbRes.T("ItemsPerPage", "Labels"))))
                .Filterable(ftb => ftb.Mode(GridFilterMode.Menu))
                .HtmlAttributes(new { style = "min-height:500px;" })               
                .ProxyURL(Url.Action("ExcelExport", "Users"))
            )
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .ServerOperation(true)
                .Read(read => read.Action("FetchUsers", "Users"))
                .Model(model => model.Id(t => t.UserID))
            )
        )

 

 

Thanks,

Nick

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Mar 2020, 01:19 PM

Hello Nick,

 

Usually this happens due to the lack of one setting - for Core projects with Grid, also make sure that you have the following setting added to your project:
.AddJsonOptions(options =>
            options.SerializerSettings.ContractResolver = new DefaultContractResolver());

As mentioned here:
https://docs.telerik.com/aspnet-core/getting-started/getting-started
 

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
1
Vincent
Top achievements
Rank 1
Iron
answered on 28 Mar 2020, 01:20 PM

In .NET core 3.1, you must set as follow:

 services.AddRazorPages().AddRazorPagesOptions(options =>
            {
                options.Conventions.AuthorizePage("/_Layout");
                options.Conventions.AuthorizePage("/_ValidationScriptsPartial");
                options.Conventions.AuthorizePage("/_ViewImports");
                options.Conventions.AuthorizePage("/_ViewStart");
                options.Conventions.AuthorizePage("/Helper");
                options.Conventions.AuthorizePage("/Index");
            }).AddNewtonsoftJson(options =>
            options.SerializerSettings.ContractResolver = new DefaultContractResolver());//for razor page

0
Gurdip
Top achievements
Rank 1
answered on 19 Aug 2020, 08:42 AM

I have this in my startup. Is this not correct?

 

    services
                .AddControllersWithViews()
                .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
                // Maintain property names during serialization. See:
                // https://github.com/aspnet/Announcements/issues/194
                .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

0
Eyup
Telerik team
answered on 20 Aug 2020, 03:02 AM

Hi Gurdip,

 

I've sent you a working sample in the official support thread. I suggest that we continue our technical conversation there.

 

Regards,
Eyup
Progress Telerik

Tags
General Discussions
Asked by
Nick Gilbert
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Vincent
Top achievements
Rank 1
Iron
Gurdip
Top achievements
Rank 1
Share this question
or