我正在使用資料表 jquery。我想在 td 標簽的資料 ID 中使用 Sr_no,但如何獲取 Sr_no 的資料。
或者你可以說我想要來自資料回應的特定資料
我在代碼中突出顯示
$("#fir").dataTable({
"bProcessing": true,
"sAjaxSource": "paid.php",
"sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
"sPaginationType": "full_numbers",
"aoColumns": [
{"mData": "Sr_no"}, <------ I dont want to add this column in table but I want to use value
{"mData": "Category_Name"},
{"mData": "Vendor_Name"},
{"mData": "date"},
{"mData": "Price"},
{"mData": "Payment_Mode"},
{"mData": "remark"},
{"mData": "edit"},
{"mData": "cancel"}
],
'columnDefs': [
{
'targets': 1,
'createdCell': function (td, cellData, rowData, row, col) {
console.log(row,col);
$(td).attr('data-id',Sr_no); <----------------
}
}
]
});
uj5u.com熱心網友回復:
您可以使用rowData.Sr_no來獲取Sr_no每行的值。更改targets: 1為
{
'targets': 1,
'createdCell': function (td, cellData, rowData, row, col) {
console.log(row,col);
$(td).attr('data-id', rowData.Sr_no);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/467546.html
標籤:javascript jQuery 阿贾克斯 数据表
上一篇:如何“向后”搜索字串?
