【问题标题】:Binding DataTable to jTable grid将 DataTable 绑定到 jTable 网格
【发布时间】:2013-08-16 19:38:34
【问题描述】:

当我将结构列表绑定到 jTable 网格时,它可以工作。例如,我的结构如下:

class A {
    public string c1 = "test-c1";
    public string c2 = "test-c2";
}

在我的控制器中,如果我将List<A> 作为 JSON 返回到 jTable 的加载方法,它可以正常工作。 jTable 正在显示网格。

代码是

return Json(new { Result = "OK", Records = obj of List<A>, TotalRecordCount = studentCount });

如果我在 DataTable 中有相同的,如下所示

C1 C2
Test-c1 Test-C2

其中 C1 和 C2 是数据列,当我使用上述语句返回 dt 时

return Json(new { Result = "OK", Records = dt, TotalRecordCount = studentCount });

理论上,DataTable 也是 Rows 的列表。那么为什么这不起作用呢?

【问题讨论】:

  • 检查生成的json,看看两个结果有何不同。
  • 如何检查生成的 JSON?

标签: c# asp.net-mvc grid jquery-jtable


【解决方案1】:

这不起作用,因为 jtable 期望包含键值对的 Json 来绑定数据。 如果用浏览器断点查看 javascript 上生成的记录属性,就会发现问题。

希望这对其他人有所帮助。 问候,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-06-08
    • 2021-10-23
    • 2013-07-28
    • 1970-01-01
    相关资源
    最近更新 更多