0

控制器

public List<Employee> Get()
{
    var ramadrmasextsOL = from a in db.EmpMas
                          select new KendoApplication.Models.Employee
                          {
                              EmployeeName = a.EmpNm,
                              EPFNumber = a.EPFNo,
                              NameWithInitial = a.NameInInitials
                          };
        return ramadrmasextsOL.ToList();
}

看法

<div id="employeesGrid"></div>

<script>
    $(function () {
        $("#employeesGrid").kendoGrid ({
            columns: [
                { field: "EmployeeName", title: "Employee Name" },
                { field: "EPFNumber", title: "EPF Number" },
                { field: "NameWithInitial", title: "Name With Initial" }
            ],
            pageable: true,
            dataSource: new kendo.data.DataSource({
                transport: {
                    read: "Home/Get"
                }
            })
        });
    });
</script>

员工模型

    public class Employee
    {
        public string EmployeeName { get; set; }
        public string EPFNumber { get; set; }
        public string NameWithInitial { get; set; }
    }

输出 -

请你帮我解决这个问题,我已经附上了这个问题的控制器、视图、模型,问题是表没有填充相关的数据库数据,这些数据只填充了空网格。

4

1 回答 1

0

不是List<Employee>控制器返回,而是返回JSON

public JsonResult Get()
{
    var ramadrmasextsOL = from a in db.EmpMas
        select new KendoApplication.Models.Employee
        {
            EmployeeName = a.EmpNm,
            EPFNumber = a.EPFNo,
            NameWithInitial = a.NameInInitials
        };
    return Json(ramadrmasextsOL, JsonRequestBehavior.AllowGet);
}

剑道JSON很好理解.. :)

于 2013-06-25T05:18:57.450 回答