【问题标题】:Not able to print the child table values in bootstarap bootgrid无法在引导引导网格中打印子表值
【发布时间】:2015-07-28 08:25:31
【问题描述】:

JSON 响应:

{
    "current": 1,
    "rowCount": 10,
    "rows": [
        {
            "id": 19,
            "sender": "123@test.de",
            "received":"[
        {
            "name":"received1"
        }
    ]
        }
    ]
},
{
    "id": 14,
    "sender": "123@test.de",
    "received":  [
        {
            "name":"received2"
        }
    ]
},
    ...],
"total": 1123}

我想使用 bootgrid 打印收到的名称。

例子:

<th data-column-id="id" data-identifier="true">Id</th>
<th data-column-id="received.name">Name</th>

我可以打印received.name,但不能打印id

【问题讨论】:

  • 首先,确保你的 json 是正确的。
  • 您提供的 JSON 无效。请检查。
  • 它的编辑问题:P,现在我已经改变了。我也发布了答案。

标签: jquery-bootgrid


【解决方案1】:
{
    "current": 1,
    "rowCount": 10,
"total": 123
    "rows": [
        {
            "id": 19,
            "sender": "123@test.de",
            "received":"received1"
        },
{
            "id": 20,
            "sender": "123@testasdasd.de",
            "received":"receisaddved1"
        }
]
}

// 这是填充网格的方法我的朋友。

【讨论】:

    【解决方案2】:

    对于上述问题,我们必须在 bootstrap bootgrid 中使用 data-formatter。

    我已在此处附上代码,希望对您有所帮助。

    <script>  $("#MyTable").bootgrid({
                ajax: true,formatters: {
                    "link": function (column, row) 
                    {
                        return "<span>" + row.received.name+ "</span>";
                    }
                }}); 
    </script>
    

    你的 HTML 会喜欢

     <table>
     <th data-column-id="received.name" data-formatter="link">Anything</th> 
     </table>
    

    【讨论】:

      猜你喜欢
      • 2014-04-07
      • 2016-12-13
      • 2023-04-09
      • 1970-01-01
      • 2023-03-24
      • 2016-08-27
      • 2017-10-02
      • 2021-12-23
      • 1970-01-01
      相关资源
      最近更新 更多