我试图仅在选定的行或行中定位一些单元格值。 我已尝试过以下代码段中所述的代码,但它会继续定位第一行,而不是选定的代码,
请原谅我,因为表中的复选框没有显示,您仍然可以通过按shift并单击复选框的位置来使用多选
var tablenest = $('#RegSrc').DataTable({
select: true,
"bPaginate": false,
"bFilter": false,
responsive: true,
deferRender: true,
"processing": true,
"serverSide": false,
bAutoWidth: true,
data: [{
"RecID": 2383,
"PtFilenum": 15090248,
"PrtFilenum": 13090701,
"Fullname": " sadden ",
"PrtStatus": 1
}, {
"RecID": 2384,
"PtFilenum": 15090248,
"PrtFilenum": 15120996,
"Fullname": "marwam mohmmad saleem",
"PrtStatus": 1
}, {
"RecID": 2385,
"PtFilenum": 15090248,
"PrtFilenum": 170227111,
"Fullname": "asd dsf a",
"PrtStatus": 1
}],
order: [2, 'asc'],
keys: {
columns: ':not(:first-child)',
keys: [9]
},
columns: [{ // Checkbox select column
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false,
"width": "1%"
},
{
"width": "50%",
data: "RecID",
"visible": false
},
{
"width": "50%",
data: "PtFilenum",
"visible": false
},
{
"width": "10%",
data: "PrtFilenum"
},
{
"width": "40%",
data: "Fullname"
},
{
"width": "10%",
data: "PrtStatus",
render: function(data, type, row) {
if (type === 'display') {
if (data == 1) {
return 'Partners';
} else {
return 'Not Partners';
}
}
return data;
},
className: "dt-body-center"
},
{
"width": "10%",
data: [],
defaultContent: 'update',
orderable: false,
className: "dt-body-center",
"visible": true
},
],
});
$("#btn1").click(function() {
tablenest.rows({
selected: true
}).every(function(rowIdx, tableLoop, rowLoop) {
tablenest.row(this).cell(rowIdx, 6).data("delete")
var row = tablenest.row( this ).node();
$(row).addClass('highlight');
});
return false;
})

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/dt/jqc-1.12.4/moment-2.18.1/dt-1.10.15/b-1.3.1/se-1.2.2/datatables.min.js"></script>
<button id="btn1" class="btn btn-primary">Mark For Delete</button>
<table id="RegSrc" class="table table-bordered table-striped table-condensed mb-none display responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th><b>RecID</b></th>
<th><b>Patient File Number</b></th>
<th><b>Partner File Number</b></th>
<th><b>Patient Name</b></th>
<th><b>Status</b></th>
<th><b></b></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
&#13;
答案 0 :(得分:3)
宾果,
PrtTbl.rows({ selected: true }).every(function (rowIdx, tableLoop, rowLoop) {
PrtTbl.row(this).cell(rowIdx,2).data("").draw()
PrtTbl.row(this).cell(rowIdx, 3).data("").draw()
});
我编辑了上面的例子