Hello,
I created the code with "The generator", because I have little knowledge of js.
I've the following error "DataTables warning: table id=vehicles - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3"
I've read de documentation about this error and I know that provides from double initialisation the but after several attempts, I'm unable to find the correct solution. I'm only want to fix first column in a datatable editor.
This is the debug: http://debug.datatables.net/aheqiy.
This is my code:
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
"ajax": "php/table.vehicles.php",
"table": "#vehicles",
"fields": [
{
"label": "matricula",
"name": "matricula"
},
{
"label": "id_personal",
"name": "id_personal"
},
{
"label": "model",
"name": "model"
},
{
"label": "renting",
"name": "renting"
},
{
"label": "inici_renting",
"name": "inici_renting"
},
{
"label": "final_renting",
"name": "final_renting"
},
{
"label": "quota",
"name": "quota"
},
{
"label": "asseguran\u00e7a",
"name": "asseguranca"
},
{
"label": "inici_ass",
"name": "inici_ass"
},
{
"label": "final_ass",
"name": "final_ass",
"type": "date",
"dateFormat": "dd\/mm\/y"
},
{
"label": "quota_ass",
"name": "quota_ass"
},
{
"label": "franquicia",
"name": "franquicia"
},
{
"label": "pag_fran",
"name": "pag_fran"
},
{
"label": "proper_itv",
"name": "proper_itv"
}
]
} );
// Activate an inline edit on click of a table cell
$('#vehicles').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this );
} );
$(document).ready(function() {
var table = $('#vehicles').DataTable( {
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
paging: false
} );
new $.fn.dataTable.FixedColumns( table );
} );
$('#vehicles').DataTable( {
"dom": "Tfrtip",
"ajax": "php/table.vehicles.php",
"scrollX": "100%",
"columns": [
{
"data": "matricula"
},
{
"data": "id_personal"
},
{
"data": "model"
},
{
"data": "renting"
},
{
"data": "inici_renting"
},
{
"data": "final_renting"
},
{
"data": "quota"
},
{
"data": "asseguranca"
},
{
"data": "inici_ass"
},
{
"data": "final_ass"
},
{
"data": "quota_ass"
},
{
"data": "franquicia"
},
{
"data": "pag_fran"
},
{
"data": "proper_itv"
}
],
"tableTools": {
"sRowSelect": "os",
"sRowSelector": 'td:first-child',
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );
}(jQuery));