为什么有时候kendo UI Grid无法显示数据?

时间:2016-05-17 10:09:12

标签: javascript jquery-ui kendo-ui

我的问题是:当我更改db.Contacts.Where(x => x.Id> 100)。选择(...)时,KendoUI Grid无法显示数据。然而,当x => x.Id< 100,它可以显示数据。 如果我删除Where(...),它也无法显示数据。

有什么不对?非常感谢你。

这是我的代码。

    public class HelloOneController : Controller
    {
           ......
        public JsonResult Contacts_Read()
        {
            var query = db.Contacts.Where(x => x.Id < 100 )
                .Select(x => new
                {
                    Id = x.Id,
                    Email = x.Email,
                    FirstName = x.FirstName,
                    LastName = x.LastName

                }).ToList();
            }

            return Json(query, JsonRequestBehavior.AllowGet);

        }
             ......
    }


$("#grid").kendoGrid({
    dataSource: {
        transport: {
            read: "/HelloOne/Contacts_Read",
            dataType: "json"
        },
        schema: {
            model:{
                fields: {
                    Id: { type: "number" },
                    Email: { type: "string" },
                    FirstName: { type: "string" },
                    LastName: { type: "string" }
                }
            }
        },
        pageSize: 20
    },
    height: 500,
    groupable: false,
    sortable: true,
    pageable: {
        refresh: true,
        pageSizes: true,
        buttonCount: 5
    },

    columns: [
        { title: "Id", field: "Id", width: 50 },
        { title: "Email", field: "Email" },
        { title: "First Name", field: "FirstName" },
        { title: "Last Name", field: "LastName" }
    ]

});

0 个答案:

没有答案