2016-04-13 36 views
1

我正在使用JQuery Bootgrid为我的表格显示,分页,搜索等。我不喜欢它是命令按钮,我只是想添加简单的html按钮我的表,如:使用PHP将我自己的按钮添加到Bootgrid表格

echo "<td><a href='expensereport.php?source=editexpenses&p_id=$expenseID'><button class='btn btn-primary btn-icon' type='button'><span class='zmdi zmdi-edit'></span></button></a>"; 

,直到我用

<table id="data-table"> 

这tuirns上bootgrid这种做法的伟大工程。 Bootgrid根本不会在我的表格中显示按钮。有谁知道如何关闭bootgrid命令按钮,以便我可以添加自己的?我的按钮很好用,直到我添加bootgrid,它拒绝在我的表格中显示它们。感谢您的帮助我是Bootgrid的新手。

回答

1

查看使用Formatters

创建一个列,每个单元格包含您的$expenseID

确保data-column-id设置在费用ID列标题上。在这个例子中,我们将它设置为data-column-id="expenseId"。您也可以通过将data-visible-in-selection='false'data-visible='false'添加到列头来完全隐藏该列。

在“动作”的列标题中,您还需要通过传递data-formatter来指定要使用的格式化程序。在这种情况下,我已经命名格式化函数expenseReportEdit,所以我们将使用data-formatter="expenseReportEdit"

为表头你的HTML标记会是这样的..

<thead> 
    <tr> 
     <th data-column-id="expenseId" data-identifier='true' data-visible-in-selection='false' data-visible='false'>Expense ID</th> 
     <th data-column-id="expenseActions" data-formatter="expenseReportEdit">Actions</th> 
    </tr> 
</thead> 

然后创建您的格式化功能,像这样..

$("#yourTableId").bootgrid({ 
    formatters: {      
     expenseReportEdit: function (column, row) { 
      return "<a href=\"expensereport.php?source=editexpenses&p_id=" + row.expenseId + "\"><button class='btn btn-primary btn-icon' type='button'><span class='zmdi zmdi-edit'></span></button></a>"; 
     } 
    } 
}); 
+0

如果我有多个按钮,一个用于删除,一个用于添加,一个用于编辑? –

相关问题