在单元格中使用HTML的Bootgrid

时间:2015-02-24 09:22:20

标签: jquery html asp.net-mvc razor twitter-bootstrap-3

我在我的Asp.net MVC5项目中使用Bootgrid来显示一些数据:

<table id="grid-basic" class="table table-condensed table-hover table-striped">
<thead>
    <tr>
        <th data-column-id="id">ID</th>
        <th data-column-id="name">Name</th>
        <th data-column-id="actions">Actions</th>
    </tr>
</thead>
<tbody>
    @foreach (Test item in Model)
    {
        <tr>
            <td>@item.Id</td>
            <td>@item.Name</td>
            <td>
                <span class="glyphicon glyphicon-search" aria-hidden="true"></span><b>Some Text</b>
            </td>
        </tr>
    }
</tbody>
</table>

问题是bootgrid删除了我的HTML代码而没有显示我想要使用的任何图标。有谁知道如何在我的单元格中使用html,我无法在bootgrid文档中找到答案?

1 个答案:

答案 0 :(得分:2)

好的,我找到了一个适合我的解决方案: 我可以使用数据格式化程序:

$("#grid-basic").bootgrid({

    caseSensitive: false,
    columnSelection: false,

    formatters: {
        "commands": function (column, row) {
            return '<span class="icon glyphicon input-group-addon glyphicon-search"></span>';
        }
    }

});

<th data-column-id="actions" data-formatter="commands">Actions</th>