Can we set ClassName dynamically based on the cell data, similar to render.
Can we set ClassName dynamically based on the cell data, similar to render.
borconi
Posts: 56Questions: 19Answers: 1
I think example is easier, basically I want to add a class just to some of the cells, not all of them, I thought I can do it like this, but doesn't seems to be working. row/data/type are undefined inside the function call. Any suggestion on how can I achive this?
Thank you.
var curr_table=$('#example').DataTable({
paging: false,
info:false,
ajax: "my_players_data.php?eventid=<?php echo $_GET['eventid'];?>",
"pageLength": -1,
scrollY: $(document).height()-170,
dom: 'Bfrtip',
columns: [
{data:'team_name' },
{data:'player_name', className:function(data,type,row) {if (row.player_name !='whatever_is_needed') return "editable"; }},
{data:'email', className:function(data,type,row) {if (row.player_name !='whatever_is_needed') return "editable"; }},
{data:'mobile', className:function(data,type,row) {if (row.player_name !='whatever_is_needed') return "editable"; }},
{data:'position', className:function(data,type,row) {if (row.player_name !='whatever_is_needed') return "editable"; }},
{data:'player_code' },
{ data: null,
"render": function ( data, type, row ) {
var qr = qrcode(4, 'L');
qr.addData(row.player_code);
qr.make();
return qr.createSvgTag(5.5,0);
}}
],
select: false,
buttons: [
{extend:'excelHtml5', exportOptions: { columns: [ 0, 1, 5,6 ] }}
]
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You might be able to use
createdRow
to accomplish your requirement.Kevin
Thanks, that will do the trick.