这里是我的行动方法不能与剑道UI网格数据绑定
public ActionResult Kendo([DataSourceRequest]DataSourceRequest request)
{
var emp = EmployeeManager.GetAllEmployees();
DataSourceResult result = emp.ToDataSourceResult(request);
return Json(result);
}
这是我从官方网站
@model IEnumerable<MyProject.Web.Models.EmployeeViewModels.EmployeeViewModel>
@using了我的网格码Kendo.Mvc.UI;
@(Html.Kendo().Grid<TalentPro.Employees.Employee>()
.Name("grid")
.DataSource(dataSource => dataSource //Configure the Grid data source.
.Ajax() //Specify that Ajax binding is used.
.Read(read => read.Action("Kendo", "Home")
) //Set the action method which will return the data in JSON format.
)
.Columns(columns =>
{
//Create a column bound to the ProductID property.
columns.Bound(product => product.Id);
//Create a column bound to the ProductName property.
columns.Bound(product => product.FirstName);
//Create a column bound to the UnitsInStock property.
columns.Bound(product => product.LastName);
columns.Bound(product => product.EmailId);
columns.Bound(product => product.PhoneNumber);
})
.Pageable() // Enable paging
.Sortable() // Enable sorting
)
我已经通过它帮助我剑道UI与我Asp.net核心项目整合官方文档了。但我不知道我出错的地方,它没有将数据与网格绑定。
我一直在尝试多种方式,但没有用。任何人都可以帮我解决这个问题。
在此先感谢。
JsonRequestBehavior在核心1.0中已折旧根据某人的建议,我将ActionResult更改为JsonResult。但没有用 –
我很抱歉,我没有注意到您使用的版本。 您也可以尝试用IActionResult替换返回类型,并用Ok(结果)替换Json(result)。 ActionResult,JsonResult和IActionResult返回类型都应该与Json return一样工作,所以我不再确定那是你的问题。 –
您是否在控制器方法中设置了断点以查看它正在被调用?是否有错误被抛出? –