Column color when reload ajax
Column color when reload ajax
andrii.radkovskii
Posts: 20Questions: 0Answers: 0
Hello All, Help me please.
I'm having trouble rebooting AJAX, when I restart ajax, then the color of the column disappears.
Maybe, someone knows how to solve this problem?
My render code.
Video - https://drive.google.com/file/d/1uXXtXEIkoXw-u4MSZ4RY7WsOVcgyrD0D/view?usp=sharing
My full code - https://pastebin.com/iFUwRsV1
"render": function (data, type, full, meta) {
var cellText = $(data).text();
if (type === 'display' && (cellText == "Так" || data == 'Так')) {
var rowIndex = meta.row + 1;
var colIndex = meta.col + 1;
$('#table tbody tr:nth-child(' + rowIndex + ') td:nth-child(' + colIndex + ')').css('background-color', '#ff9797').css('color', '#ffffff');
return data;
} else {
return data;
}
}
This discussion has been closed.
Replies
Interesting demo, thanks,. My guess is that the
rowIndex
and/orcolIndex
are not what you expect them to be during reload. Hard to say though without seeing it in action. You could try someconsole.log
statements in your render function to see what's happening.However using
columns.render
is not intended for manipulating thetr
elements. You should usecreatedRow
orrowCallback
orcolumns.createdCell
for this.Kevin
@kevin Thanks!!! I used this code! Maybe someone else will come in handy.
live.datatables.net/yiceculu/1/edit