I'm trying to add some buttons in the DataTable using columnDefs
, but I can not, and when I remove some columns, it does not align in the order
My current code is this:
var grid = $("#grid").dataTable({
"language": {
"url": "/Scripts/libs/dataTable/ptBr.txt"
},
"ajax": "/grupo/data",
"columnDefs": [
{
"data": "Id",
"targets": 0
},
{
"data": "Nome",
"targets": 1
},
{
"data": "Descricao",
"targets": 2
},
{
"render": function (data, type, row) {
return "<a href='/editar/" + row.Id + "' class='btn btn-primary'>Editar</a>"
},
"targets": 3
},
{
"render": function (data, type, row) {
return "<a href='/editar/" + row.Id + "' class='btn btn-danger'>Deletar</a>"
},
"targets": 4
}
]
});
and gives the following error:
Can not read property 'style' of undefined
And it does not even render data
But if I remove the columns from the links, it appears the data