I need to know, if is possible initialize a DataTable from JQuery, with server side processesing without indicate the property "columns", or if not, how to indicate it dynamically.
When I initialize the DataTable just like that
var InicialiceLaTablaDeUsuarios = function () {
var laTabla = $('#TablaDeUsuarios').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/Usuarios/ConsulteLosUsuarios",
"type": "POST",
"dataType": "JSON"
},
"deferRender": true,
"serverSide": true,
"searchDelay": 800,
"autoWidth": true,
"stateSave": true,
"columns": [
{ "data": "Apellido1" },
{ "data": "Apellido2" },
{ "data": "Clave" },
{ "data": "CorreoElectronico" },
{ "data": "Estado" },
{ "data": "Id" },
{ "data": "Nombre" }
]
});
return laTabla;
}
it works perfectly, but if I try to initialize DataTable just like that
var InicialiceLaTablaDeUsuarios = function () {
//
var laTabla = $('#TablaDeUsuarios').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/Usuarios/ConsulteLosUsuarios",
"type": "POST",
"dataType": "JSON"
},
"deferRender": true,
"serverSide": true,
"searchDelay": 800,
"autoWidth": true,
"stateSave": true
});
return laTabla;
}
it doesn't work and throw the next error.
Thanks for your time.
Greetings.

<thead>tag in your table.