[英]Jquery: add custom row in datatables
I created an html page, which contains five columns. 我创建了一个html页面,其中包含五列。 The last one contains a button. 最后一个包含一个按钮。 (Each row has a button in the last column). (每行在最后一列中都有一个按钮)。
I'm using datatables plugin: 我正在使用datatables插件:
var oTable = $(".datatable-fn").dataTable({
sPaginationType: "full_numbers"
});
Now I need to add new row to the tables. 现在我需要向表中添加新行。 I know that exists fnAddData
function that do this, but I don't know how can I add the button in the last cell of the row. 我知道存在执行此操作的fnAddData
函数,但我不知道如何在行的最后一个单元格中添加按钮。
You can add any HTML content in the new cells: 您可以在新单元格中添加任何HTML内容:
$('#example').dataTable().fnAddData( [
giCount+".1",
giCount+".2",
giCount+".3",
"<button>My button</button>" ] );
Using createElement : 使用createElement :
var button = document.createElement("button");
button.innerHTML = "My button";
$('#example').dataTable().fnAddData( [
giCount+".1",
giCount+".2",
giCount+".3",
button.outerHTML ] )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.