0

有一种方法可以<br>使用 jquery-bootgrid 使单元格内部的 a 可见?因为渲染<br>是不可见的。

4

2 回答 2

2

我的理解是你想在你的数据中添加一个换行符,像这样,

在此处输入图像描述

在 features 列中,我传递了一个数组,并使用它在单独的行中显示每个 Item<br>

为此,您可以创建一个自定义转换器,

http://www.jquery-bootgrid.com/Documentation#converters

您可以在初始化 BootGrid 表时创建转换器

var dt = $('#myTable').bootgrid({
  //.......... Other Options
  converters: {
    listDisplay: {
      from: function(value) {
        return value;
      },
      to: function(value) {

     // Here you can customise value - I have an Array which I join using <br>

        value.sort();
        value = value.join("<br/>");
        return value;
      }
    }
  }
});

然后,您在 Table HTML 中所要做的就是在 Column 标题上设置数据类型

    <table  id="myTable">
      <thead>
        <tr>
          <th data-column-id="Id" data-visible="false" data-identifier="true" data-type="numeric">Id</th>

          <th data-column-id="SelectedFeaturesNames" data-type="listDisplay">Features</th>

<!-- Note the data-type on the Features <th> is listDisplay -->

        </tr>
      </thead>
      <tbody></tbody>
    </table>
于 2016-05-05T14:56:02.903 回答
0

使用这种方法有效吗?

是的@Dawood Awan!它对我有用

PHP:

<td>
    <?php
        $test = ['b', 'a', 'c'];
        echo json_encode($test);
    ?>
</td>

JS:

to: function(value) {
    value = JSON.parse(value); //convert received json to js array.
    value.sort();
    value = value.join("<br/>");
    return value;
}
于 2016-05-09T16:06:17.967 回答