Using Laravel 5.8 and Yajra datatables I have a table and I want to replace 1 with an icon or if 0 return a blank.
In my javascript I have:
"columnDefs": [{
"targets": 5,
"render": function ( data, type, row ) {
if ( data == "1" )
{return '<i class="fas fa-check-circle"></i>';}
else if ( data == "0" )
{ return ' ';}
},
}],
This works fine
but my problem is adding a second cell:
"columnDefs": [{
"targets": 5,
"render": function ( data, type, row ) {
if ( data == "1" )
{return '<i class="fas fa-check-circle"></i>';}
else if ( data == "0" )
{ return ' ';}
},
"targets": 6,
"render": function ( data, type, row ) {
if ( data == "1" )
{return '<i class="fas fa-check-circle"></i>';}
else if ( data == "0" )
{ return ' ';}
},
}],
The first column (5) is back to zeros and ones but the column 6 is correct.
Help greatly appreciated indeed!
via Chebli Mohamed


Aucun commentaire:
Enregistrer un commentaire