2015-02-24 89 views
1
我在我的Asp.net MVC5项目中使用Bootgrid

使用HTML来显示一些数据: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文档中找不到答案。

回答

2

好吧,我发现我工作的解决方案: 我可以使用数据formaters:

$("#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>