I have one DataTable which is:
export default class TablaMisIncidencias extends React.Component {
constructor() {
super();
}
componentDidMount() {
$('#idTablaMisIncidencias').DataTable({
responsive: true,
"paging": true,
"ordering": true,
select: false,
"lengthMenu": [[5, 10, 25, -1], [5, 10, 25, "Todas"]],
columnDefs: [
{
responsivePriority: 1,
targets: 0
},
{
responsivePriority: 2,
targets: 1
},
{
responsivePriority: 3,
targets: 5
},
{
responsivePriority: 4,
targets: 2
},
{
responsivePriority: 5,
targets: 3
},
{
responsivePriority: 6,
targets: 4
}
],
"ajax": {
"url": "https://jsonplaceholder.typicode.com/comments",
"dataSrc": ""
},
"columns": [
{ "data": "postId" },
{ "data": "id" },
{ "data": "name" },
{ "data": "name" },
{ "data": "body" },
{ "data": "body",
sortable: false,
//HERE IS THE ERROR
"render": function ( data, type, full, meta ) {
//console.log(full)
if (full.postId == 0) {
return (`
<Link to="eee" class='btn btn-info btn-xs' title="Editar"><span class="glyphicon glyphicon-edit"></span> Editar</Link>
`);
} else {
return (`
<a href="eee" class='btn btn-success btn-xs' title="Tramitada"><span class="glyphicon glyphicon-ok"></span> Tramitada</a>
`);
}
}
},
]
});
}
If you see comment line: //HERE IS THE ERROR, on this function render I have two returs which are very similar. If postId == 0 it may returns one Link
else may return one a
. Both a
and Link
are the same. The unique difference is a
is an HTML Tag and Link
is a React-Router Tag. Well, when render returns a
it is showed as a button (that is that I want, but I want that it happen too with Link); when render returns Link
it is showed as text and the glyphicon, all separate, do not showed as button, and do not redirect neither. So, Why a
is returned well and Link
is not returned well? How could I solve this?
Thank you.