剑道网格中的寻呼机错误(Nan-Nan of 1 items)

我正在尝试创建一个包含学生详细信息列表的Kendo网格。 点击添加按钮,寻呼机显示“Nan-Nan of 1 items”。

@(Html.Kendo().Grid() .Name("StudentDetailsGrid") .Pageable() .HtmlAttributes(new { id="StudentDetailsGrid"}) .Columns(col => {col.Bound(a => a.FirstName).Title("Name"); col.Bound(a => a.LastName).Hidden() col.Bound(a => a.StudentID).Hidden(); col.Command(a => { a.Destroy(); a.Edit(); }).Title(""); } ) .ToolBar(toolbar => toolbar.Create().Text("Add").HtmlAttributes(new {@id="btnCreateStudent"})) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Scrollable(scrol => scrol.Enabled(true)) .DataSource(source => source .Ajax() .PageSize(5) .Model(a => { a.Id(b => b.StudentID); }) .Read(read => read.Action() .Create(create => create.Action()) .Destroy(destroy => destroy.Action()) .Update(update => update.Action()) ).Events(even => even.Save("SaveDetails").Edit("ChangeNoOfStudent").DataBound("StudentValidate"))) 

`

在Document.ready函数上:

 $(document).ready(function () { $.ajax({ url: '../Student/GetStudentDetails?StudentId=' + Data.StudentId, type: 'POST', contentType: 'application/json', dataType: 'json', success: function (data) { if (data.length > 0) { var studentdetail = new kendo.data.DataSource({ data: data, pageSize: 5 }); $("#StudentDetailsGrid").data("kendoGrid").setDataSource(studentdetail); } 

我已经添加了页面大小,但我仍然可以看到“Nan-Nan of 1 items”。

你能帮忙吗?

您需要在网格数据源中定义pageSize。 不在成功function中。

在您的情况下,您只需要在数据源中包含以下内容:

  $.ajax({ url: '../Student/GetStudentDetails?StudentId=' + Data.StudentId, type: 'POST', contentType: 'application/json', dataType: 'json', pageSize: 10, success: function (data) {... 

我希望这有帮助。 更多信息: Sudarsan Dash’blogs

我让它像下面这样工作:指定数据源内的pagesize修复了我的问题(Nan-Nan of 1 items)

 < script type = "text/javascript" > $(document).ready(function() { var modelData = @Html.Raw(Json.Encode(Model)); $("#grid").kendoGrid({ reorderable: true, pageable: { input: true, numeric: false }, scrollable: true, sortable: true, dataSource: { data: modelData, pageSize: 10 // specifying the pagesize inside the datasource fixed my problem (Nan-Nan of 1 items) }, columns: [{ field: "fieldparameter", title: "titleparameter", filterable: true, sortable: true }] }); }); < /script> 

这是您解决问题所需的。 像梦一样工作!

  

在dataSource:{}里面添加pageSize:5,

  dataSource: { pageSize: 5 } 

如果你把pageSize:5放在dataSource:{}之外你会得到那个错误“Nan-Nan”

从@(Html.Kendo()。Grid()中删除.PageSize(5)在var studentdetail中添加pageSize:5 = new kendo.data.DataSource({

出于某种原因,只是将pageSize添加到我的数据源对我来说不起作用。

我通过将初始网格页面设置为1解决了这个问题,并且我的pageSize也在我的数据源中定义:

  var grid = $("#grid").data("kendoGrid"); var dataSource = new kendo.data.DataSource({ data: response.data }); grid.setDataSource(dataSource); grid.dataSource.page(1); // need so that Nan - Nan is not the starting page. grid.dataSource.read();