【问题标题】:Empty datat to jqgrid to diaplay No Data in the Grid将数据清空到 jqgrid 以在 Grid 中显示 No Data
【发布时间】:2013-02-20 12:21:41
【问题描述】:

我有一个 JQGrid,并且正在通过 Ajax 调用加载数据到 MVC 控制器。在控制器中,它是一个 DataTable,它正在转换为 Class 和运行时并返回 JSON。

if (data.Rows.Count > 0)
 {
 List<Classs> item = new List<Classs>();
 var result = new
 {
 total = (int)Math.Ceiling((double)count / grid.PageSize),
  page = grid.PageIndex,
 records = count,
  rows = (from i in data.AsEnumerable()
  select new Classs
  {
                       xx= i.Field<string>("x"),
                       yy= i.Field<string>("y"),

    }).ToArray()
        };
 return Json(result, JsonRequestBehavior.AllowGet);

  }

在其他部分,如果表格为空,我如何返回数据以便网格显示“未找到记录”?

谢谢

【问题讨论】:

    标签: c# asp.net-mvc jqgrid


    【解决方案1】:

    即使结果为空,您也可以传递 JSON 结果。如果要显示的数据为 0,则可以通过 userdata 参数传递一个布尔值,或者如果没有要显示的结果(也可以通过过滤触发),您可以在客户端进行测试,例如:

      loadComplete: function () {
            if ($(this).jqGrid('getGridParam', 'reccount') == 0) {
               //display message if empty jqGrid, etc        
            }
    

    【讨论】:

    • 对于 $(this).jqGrid('getGridParam', 'reccount') 的定义变得不确定
    • 它在你的 loadComplete 里面吗?
    • 粘贴该部分,我不确定它为什么会失败,因为我直接从我自己项目的生产代码中获取了它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 2019-01-01
    • 2012-12-23
    • 1970-01-01
    • 2015-03-02
    • 2023-03-18
    相关资源
    最近更新 更多