Kendo Grid中的寻呼机错误(Nan-Nan of 1 items)

Roh*_*ini 11 javascript jquery kendo-grid

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

@(Html.Kendo().Grid<Student.Models.StudentDetails>()
            .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")))
Run Code Online (Sandbox Code Playgroud)

`

在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);

                    }
Run Code Online (Sandbox Code Playgroud)

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

你能帮忙吗?

fre*_*per 19

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

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

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

我希望这有帮助.更多信息:Sudarsan Dash'blogs


Kis*_*ore 14

我让它像下面这样工作:指定数据源内的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>
Run Code Online (Sandbox Code Playgroud)