我只是想问一下如何在按钮上添加DATA ID EDIT / DELETE这里是我的javascript用于渲染数据行 我想将数据ID放在 ROW_ID 上,比如删除?id = 1(CI:delete / 1)
$('#data').dataTable({
"sScrollY": "400px",
"bProcessing": true,
"bServerSide": true,
"sServerMethod": "GET",
"sAjaxSource": "<?php echo base_url(); ?>pages/datatable",
"iDisplayLength": 10,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"aaSorting": [[0, 'asc']],
"aoColumns": [ null, null, null,
{
"mData": null,
"sClass": "center",
"sDefaultContent": '<a href="edit.php?id=ROW_ID" class="btn">Edit</a> / <a href="delete.php?id=ROW_ID" class="btn_remove">Delete</a>',
}
]
}).fnSetFilteringDelay(700);
答案 0 :(得分:0)
假设您要在ajax中返回ID值,可以使用mRender
...
"sClass": "center",
"mRender": function ( data, type, full ) {
return '<a href="edit.php?id=' + full[0] + '" class="btn">Edit</a> / <a href="delete.php?id=' + full[0] + '" class="btn_remove">Delete</a>';
}
full[0]
是具有ID参数的数据行。如果这是在不同的列中,显然您将相应地更改索引