Asp.net core asp.net core 3.1中的剑道ui网格绑定失败

Asp.net core asp.net core 3.1中的剑道ui网格绑定失败,asp.net-core,telerik,kendo-grid,kendo-asp.net-mvc,Asp.net Core,Telerik,Kendo Grid,Kendo Asp.net Mvc,我使用的是Telerik kendo数据网格,如果我们看以下内容,我使用的是web API将数据返回到网格中。下面是我如何定义剑道阅读方法的。这个应用程序与我以前使用的应用程序的唯一区别是我使用的是.net core 3.1 我已根据Telerik文件添加了此项 但正如您在下面看到的,网格中仍然没有数据 @(Html.Kendo().Grid<Stock>() .Name("Grid") .Columns(columns => { columns.Bound(p =&g

我使用的是Telerik kendo数据网格,如果我们看以下内容,我使用的是web API将数据返回到网格中。下面是我如何定义剑道阅读方法的。这个应用程序与我以前使用的应用程序的唯一区别是我使用的是.net core 3.1

我已根据Telerik文件添加了此项

但正如您在下面看到的,网格中仍然没有数据

@(Html.Kendo().Grid<Stock>()
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.ID);
    columns.Bound(p => p.Description).Width(180);
    columns.Bound(p => p.Name).Width(180);
    columns.Command(command => command.Destroy()).Width(160);
})
.ToolBar(toolbar =>
{
    toolbar.Create();
    toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Navigatable()
.Sortable()
.Groupable()
.Filterable()
.Scrollable()
.DataSource(dataSource => dataSource
    .Ajax()
    .Batch(true)
    .PageSize(20)
    .ServerOperation(false)
    .Events(events => events.Error("error_handler"))
      .Model(model =>
    {
        model.Field(p => p.ID).Editable(false);
        model.Field(p => p.Name);
    })
     .Read("ReadStock", "Stock")
   )
)


public async Task<IActionResult> ReadStock([DataSourceRequest] DataSourceRequest request)
{
    List<Stock> _result = new List<Stock>();
    _result =await  apiClient.GetStockFromApi();
    object test  = Json(_result);
    return Json(_result);
}
我的股票班

public class Stock
{
        public int ID { get; set; } // int, not null
        public string StockCode { get; set; } // nvarchar(150), null
        public string Name { get; set; } // nvarchar(350), not null
        public string Description { get; set; } // nvarchar(max), null
        public DateTime? StartDate { get; set; } // datetime, null
        public DateTime? EndDate { get; set; } // datetime, null
        public int? WarehouseId { get; set; } // int, null
        public int? IsFreeText { get; set; } // int, null
        public decimal? QuanityInStock { get; set; } // decimal(18,5), null
        public decimal? RecordedQuantity { get; set; } // decimal(18,5), null
        public bool? UseDescription { get; set; } // bit, null
        public string Barcode { get; set; } // nvarchar(50), null
        public int? ProductGroup { get; set; } // int, null
        public int? TaxCode { get; set; } // int, null
        public decimal? PhysicalStock { get; set; } // decimal(18,5), null
        public decimal? ActualStock { get; set; } // decimal(18,5), null
        public bool? isActive { get; set; } // bit, null
        public bool? isDeleted { get; set; } // bit, null
        public DateTime? CreatedDate { get; set; } // datetime, null
        public string CreatedBy { get; set; } // varchar(100), null
        public string UOM { get; set; } // nvarchar(50), null
  }

要解决此问题,您需要在.net core 3.1应用程序中执行此操作

services.AddMvc(setupAction=> {
        setupAction.EnableEndpointRouting = false;
    }).AddJsonOptions(jsonOptions =>
    {
        jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null;
    })
    .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

您能在浏览器中打开该页面,并向我们显示服务器返回的实际响应吗?(开发者工具中的网络标签)@Kei是的,我会在家里工作present@rogue39nin你有没有找到解决办法?我也遇到了类似的问题。是的,这是因为我的json作为camal案例进行了通信。但是网格希望在普通情况下,如果你调试你的json,你会在console@Mark在我自己对问题的回答中,请参见下面我的更新答案
services.AddMvc(setupAction=> {
        setupAction.EnableEndpointRouting = false;
    }).AddJsonOptions(jsonOptions =>
    {
        jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null;
    })
    .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);