ASP.Net MVC 3 JQGrid

后端 未结 4 817
时光取名叫无心
时光取名叫无心 2020-12-09 00:27

After reading up on the JQGrid control, I decided it would be good to use it in one of my ASP.Net MVC 3 Web applications.

Firstly I followed Phil Haacks tutorial htt

4条回答
  •  悲&欢浪女
    2020-12-09 00:33

    EF doesn't support ToString method, you must retrieve the data without ToString and format

    this should work

    public ActionResult LinqGridData(string sidx, string sord, int page, int rows)
    {
        AssetEntities context = new AssetEntities();
    
        var query = from e in context.Equipments
                    select e;
    
        var count = query.Count();
    
        var result = new
        {
            total = 1,
            page = page,
            records = count,
            rows = query.Select(x => new { x.equipamentID, x.Category.categoryTitle,x.Department.title })
                        .ToList() // .AsEnumerable() whatever
                        .Select(x => new { 
                            id = x.equipamentID,
                            cell = new string[] {
                                x.equipamentID.ToString(),
                                x.categoryTitle,
                                x.title
                            }})
                        .ToArray(),
        };
    
        return Json(result, JsonRequestBehavior.AllowGet);
    
    }
    

提交回复
热议问题