代码之家  ›  专栏  ›  技术社区  ›  Juk

用于MVC数据的jQuery网格不是从控制器到视图的

  •  1
  • Juk  · 技术社区  · 14 年前

    我刚从codeplex下载了用于ASP.NET MVC的jQuery网格

    我确实运行了这个项目,所有接缝都正常,在SQL事件探查器中,我可以看到SQL查询进入数据库。然后在调试器中,我可以看到数据来自LinqToSQL查询fine:

    var model = from entity in repository.Index().OrderBy(sidx + " " + sord)
        select new
        {
            Edit = "_edit link was here_",
            Details = "_details link was here_",
            ProductID = entity.ProductID,
            ProductName = entity.ProductName,
            UnitPrice = entity.UnitPrice,
            Discontinued = entity.Discontinued == true 
                ? "<input type='checkbox' checked='checked' disabled='disabled'/>" 
                : "<input type='checkbox' disabled='disabled' />"
        };
    

    数据进入模型,模型不为空。

    然后这个数据转换成JSON,然后JSONResult进入视图:

    JsonResult jData = Json(model.ToJqGridData
        (page, rows, null, search, new[] { "ProductName" }));
    return jData;
    

    我在调试器中看到,JData中有数据,JData不是空的,看起来都不错。

    但是在视图(HTML)上,jqgrid上没有显示数据,它是空的。由于某些原因,数据不是从控制器发送到视图(jqgrid)。 我尝试了所有最新的浏览器。

    我认为问题隐藏在javascripts的某个地方,目前我正在研究这个问题。

    可能有人对此有任何想法。

    2 回复  |  直到 12 年前
        1
  •  0
  •   HeartKiller    14 年前

    这不是我的javascript:) http://jqmvcgrid.codeplex.com/

        2
  •  1
  •   dove    12 年前

    您必须在jsonDataController的函数列表中添加“jsonRequestBehavior.allowget”以下内容:

    return Json(model.ToJqGridData(page, rows, null, "", 
                new[] { "ProductName", "UnitPrice" }), JsonRequestBehavior.AllowGet);