2016-04-13 45 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

如果我有多個按鈕,一個用於刪除,一個用於添加,一個用於編輯? –

相關問題