使用 PHP 将我自己的按钮添加到 Bootgrid table
Adding my own buttons to a Bootgrid table using PHP
我正在使用 JQuery Bootgrid 用于 table 显示、分页、搜索等。我不喜欢它的是命令按钮,我只想添加简单的 html 按钮到我的 tables 例如:
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">
启动网格。 Bootgrid 在我的 table 中根本不会显示按钮。有谁知道如何关闭 bootgrid 命令按钮以便我可以添加自己的命令按钮?在我添加 bootgrid 之前,我的按钮工作得很好,它拒绝在我的 table 中显示它们。感谢您的帮助,我是 Bootgrid 的新手。
看看使用 Formatters。
创建一个列,每个单元格都包含您的 $expenseID
。
确保在费用 ID 列标题上设置 data-column-id
。对于此示例,我们将其设置为 data-column-id="expenseId"
。您也可以通过向列标题添加 data-visible-in-selection='false'
和 data-visible='false'
来完全隐藏此列。
在 "actions" 的列标题中,您还需要通过传递 data-formatter
指定要使用的格式化程序。在本例中,我将格式化程序函数命名为 expenseReportEdit
,因此我们将使用 data-formatter="expenseReportEdit"
。
您的 HTML 标记 table 头部将是这样的..
<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>";
}
}
});
我正在使用 JQuery Bootgrid 用于 table 显示、分页、搜索等。我不喜欢它的是命令按钮,我只想添加简单的 html 按钮到我的 tables 例如:
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">
启动网格。 Bootgrid 在我的 table 中根本不会显示按钮。有谁知道如何关闭 bootgrid 命令按钮以便我可以添加自己的命令按钮?在我添加 bootgrid 之前,我的按钮工作得很好,它拒绝在我的 table 中显示它们。感谢您的帮助,我是 Bootgrid 的新手。
看看使用 Formatters。
创建一个列,每个单元格都包含您的 $expenseID
。
确保在费用 ID 列标题上设置 data-column-id
。对于此示例,我们将其设置为 data-column-id="expenseId"
。您也可以通过向列标题添加 data-visible-in-selection='false'
和 data-visible='false'
来完全隐藏此列。
在 "actions" 的列标题中,您还需要通过传递 data-formatter
指定要使用的格式化程序。在本例中,我将格式化程序函数命名为 expenseReportEdit
,因此我们将使用 data-formatter="expenseReportEdit"
。
您的 HTML 标记 table 头部将是这样的..
<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>";
}
}
});