1
I’m trying to add some buttons to the Datatable using columnDefs
, but yet I can’t, and when I remove a few columns, it’s not aligned according to 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 the following error:
Cannot read Property 'style' of Undefined
And it won’t yield even the dice
But if I remove the columns from the links, it appears the data
Rod, I don’t know the
dataTable
, but the fact that the fourth column does not have thetargets
cause no problem?– Wakim
error if I remove targets
– Rod
My observation was to include the
targets: 3
in that fourth column.– Wakim
already tried Wakim, I think I forgot to post in the example, I will edit
– Rod