0
我在控制器中獲取數據並將其返回json
但在kendo網格中,我無法顯示該數據以及網格jost顯示錶和數據行發送。
我的控制器的代碼:在conroller中收到數據但未在kendo網格中顯示
private IRepository<Customer> _UserDetail;
public UserDetailsController(IRepository<Customer> UserDetail)
{
_UserDetail = UserDetail;
}
public ActionResult Manage()
{
return View();
}
[HttpPost]
public ActionResult GetUsers(DataSourceRequest userDetail)
{
var query = _UserDetail.Table.Select(x => x.Email).ToList();
var gridModel = new DataSourceResult
{
Data = query,
Total = query.Count
};
return Json(gridModel);
}
我劍術網格視圖:
<script>
$(document).ready(function() {
$("#user-details").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("GetUsers", "UserDetails"))",
type: "POST",
dataType: "json",
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
},
requestEnd: function(e) {
if (e.type == "update") {
this.read();
}
},
error: function(e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true,
numeric: false,
previousNext: false,
info:false
},
editable: {
confirmation: true,
mode: "inline"
},
scrollable: false,
columns: [
{
field: "Email",
title: "User Name",
width: 200
},
{
command: [
{
name: "edit",
text: "@T("Admin.Common.Edit")"
}, {
name: "destroy",
text: "@T("Admin.Common.Delete")"
}
],
width: 200
}
]
});
});
</script>
<div id="user-details"></div>
你得到了什麼錯誤? –
是的,我達到回答這個問題,但現在我收到沒有數據的空行。例如,我發送4個數據在JSON和網格顯示4個空行在網格和記錄沒有顯示。 – Mojtaba