我有以下数据表函数,它被禁止从服务器端绘制一个表:
function Draw() {
oTable = j("#dataTables-example").DataTable({
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "/swf/copy_csv_xls_pdf.swf"
},
stateSave: true,
"bautoWidth": false,
"aoColumns": [
{"sTitle": "Role No", "mData": "id"},
{"sTitle": "Role Name.", "mData": "name"},
{"sTitle": "Status", "mData": "status"},
{"sTitle": "Action","mData":""}
],
"bDeferRender": true,
"bProcessing": true,
"bDestroy": true,
"bLengthChange": true,
"iDisplayLength": 200,
"sAjaxDataProp": "",
"sAjaxSource": '<?php echo base_url() . "admin/roles_data"; ?>',
"aaSorting": [[2, "desc"]]
});
}
如何在以下aoColumns
mData
属性中添加HTML?
{"sTitle": "Action","mData":""}
答案 0 :(得分:0)
<强>解强>
您可以使用sDefaultContent
(DataTables 1.9)或defaultContent
(DataTables 1.10),如下所示:
"aoColumns": [
{"sTitle": "Role No", "mData": "id"},
{"sTitle": "Role Name.", "mData": "name"},
{"sTitle": "Status", "mData": "status"},
{"sTitle": "Action", "mData": null, "sDefaultContent": '<input type="button" value="Some Action">' }
],
<强>样本强>
请参阅this jsFiddle以获取代码和演示。