我正在尝试突出显示或更改jQuery Datatable中所选行的背景颜色。我正在使用rowCallback,但没有任何效果。这是我的代码://..global variable , this is id of selected rowlet selectedRowProfileId = ''; //..ready function$(document).ready(function () {if ($('#data-table').length !== 0) { $('#data-table').DataTable({ autoFill: true, "scrollX": true, "columnDefs": [ { "targets": [1], "visible": false, "searchable": false }, ], });}});//..Click event fired whenever a user click on a cell or row$('#data-table tbody').on('click', 'td', function () {const tr = $(this).closest('tr');const table = $('#data-table').DataTable();const data = table.row(tr).data();selectedRowProfileId = data[1];//..Update UIUpdateUIBySelectedProfileId(selectedRowProfileId);});UpdateUIBySelectedProfileId(selectedRowProfileId){ //..Here i do ajax call based on the selectedRowProfileId //..Upon receiving the respone in success bloc of ajax call //..i re-draw the table like this : const clients = JSON.parse(reponse); const table = $('#data-table').DataTable(); table.clear().draw(); clients.forEach(client => { table.row.add([ client['LastKnownZone'], client['ProfileId'], client['macAddress'], client['ssId'], client['Statut'],, client['LastLocatedTimeString'], ]); });所以我要实现的是在重绘表格时突出显示先前选择的行。我试图找出上述代码出了什么问题。任何帮助,将不胜感激。
添加回答
举报
0/150
提交
取消