![](/img/trans.png)
[英]I want to add edit and delete buttons in datatables using codenigator
[英]Datatables 1.10 add column for Edit and Delete buttons
我在理解如何將列“添加”到數據表1.10時遇到麻煩。 我想做這個:
從字面上看,“加”是什么意思? 如果我了解該文檔,則實際上並沒有添加任何列,僅使用此處顯示的“ columnDefs”功能用“生成的內容”覆蓋目標: https : //datatables.net/examples/ajax/null_data_source.html
這使我認為現在我必須在服務器端代碼中添加新的“空”列,以便為按鈕留一個位置。 這似乎是錯誤的,或者至少沒有效率。 因此,我發現使用columnDefs進行渲染 。
我基本上不了解它們之間的區別,但是這些似乎是唯一的選擇,似乎都沒有“創建/添加”新列。
`"data": "phone",
"render": {
"_": "plain",
"filter": "filter",
"display": "display"
}
`
問題是在哪里/如何添加額外的列,如何將按鈕添加到新列。
*我意識到也有類似的問題,但大多數問題似乎都適用於1.9或假設您了解該列的來源。
使用fnRowCallback
添加/更新行數據。
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
// to get datatable settings
var oSettings = (this.fnSettings) ? this.fnSettings() : this;
$("td:last", nRow).html('your add and delete button')
return nRow;
},
更新:如果您不想在服務器代碼中添加假列,請使用此行
$("td:last", nRow).parent().append('<td>your add and delete button</td>')
此行找到每一行的父tr
,並在td
后面附加按鈕
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.