0
我有一個jquery的數據表格,它工作正常......除了在我的頁面/表格呈現之後...它缺少一個行ID。 我需要每一行看起來是這樣的:
<tr id=10100... > ... </tr>
代碼
$(document).ready(function() {
var selected = [];
$('#users').DataTable({
"processing": false,
"serverSide": true,
"ordering": false,
aLengthMenu: [
[10, 25, 50, 100, "-1"], //controls the "Show X entries" drop down on gui
[10, 25, 50, 100, "All"]
],
"ajax": "/cgi-bin/mvspaging_list",
rowId:'pn',
"rowCallback": function(row, data) {
if ($.inArray(data.DT_RowId, selected) !== -1) {
$(row).addClass('selected');
}
},
"columns":
[
//{ "data": "id" ,"searchable":false},
{ "data": "pn", "searchable":true },
{ "data": "fname",defaultContent:'', "searchable":true},
{ "data": "lname",defaultContent:'',"searchable":true},
{ "data": "grp_name",defaultContent:'',"searchable":true},
{ "data": "description",defaultContent:'',"searchable":true},
{ "mRender": function (data, type, row) {
if (row.grp == 0) {
action = '<a href=pndetails.html?pn=' + row.pn +'>Details</a>';
var fullname= encodeURI(row.fname + " " + row.lname);
action = action + ' | ' + '<a href="#" onclick=delpn(' + row.pn + ',"' + fullname + '",false)>Delete</a>';
return action;
} else {
var groupname= encodeURI(row.grp_name);
action = '<a href=group_details.html?pn=' + row.pn +'>Details</a>';
action = action + ' | ' + '<a href="#" onclick=delpn(' + row.pn + ',"' + groupname + '",true)>Delete</a>';
return action;
}
}
}
]
});
});
目前,該生成HTML行是這樣的:
<tr role="row" class="odd">
<td>10100</td>
<td>Devin</td>
<td>Daster</td>
<td></td>
<td></td>
<td><a href="pndetails.html?pn=10100">Details</a> | <a href="#" onclick="delpn(10100,"Devin%20Daster",false)">Delete</a></td>
</tr>
我以爲指定
rowId:'pn',
會做的伎倆,但我猜不是。
關於我失蹤的任何建議將不勝感激。我目前使用此作爲參考:https://datatables.net/reference/option/rowId