Inline editor on certain columns only with Key Table - not all data passed to script
Inline editor on certain columns only with Key Table - not all data passed to script

So, I'm trying to have a table with 2 of the columns enabled for inline editing and Key Table addon enabled. I'm getting a few problems and not sure how to solve them. First my HTML code:
<table class="table table-striped- table-bordered table-hover table-checkable" id="kt_table_1">
<thead>
<tr>
<th>EAN</th>
<th>Vendor</th>
<th>Format</th>
<th>Description</th>
<th>Qty</th>
<th>Export Price</th>
<th>Buy Price</th>
<th>Status</th>
</tr>
</thead>
</table>
The 2 editable columns are supposed to be Vendor and Export Price.
My JS script looks like this:
"use strict";
var KTDatatablesDataSourceAjaxServer = function() {
var initTable1 = function() {
var table = $('#kt_table_1');
var editor = new $.fn.dataTable.Editor( {
ajax:{
edit: {
type: 'POST',
url: '/script/updateMissingExport.php'
}
},
table: "#kt_table_1",
idSrc: 'EAN',
fields: [ {
label: "EAN:",
name: "EAN"
}, {
label: "Vendor:",
name: "Vendor"
}, {
label: "Description:",
name: "Description"
}, {
label: "Qty:",
name: "Qty"
}, {
label: "Export Price:",
name: "ExportPrice"
}, {
label: "Buy Price:",
name: "BuyPrice",
attr: { type: "number" }
}, {
label: "Status:",
name: "Status"
}
],
formOptions: {
inline: {
onBlur: 'submit',
submit: 'allIfChanged'
}
}
} );
editor.on( 'preSubmit', function ( e, data, action ) {
if ( action === 'edit' ) {
$.each( data.data, function (id, value) {
console.log(value);
});
}
} );
/*
$('#kt_table_1').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this );
} );
*/
$('#kt_table_1').on( 'click', 'tbody td.editable', function (e) {
editor.inline( this );
} );
// begin first table
table.DataTable({
responsive: true,
dom: `<'row'<'col-sm-6 text-left'f><'col-sm-6 text-right'B>>
<'row'<'col-sm-12'tr>>
<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>`,
buttons: [
'print',
'excelHtml5',
'pdfHtml5',
{ extend: "edit", editor: editor }
],
keys: {
columns: [1,5],
editor: editor,
editOnFocus: true
},
searchDelay: 500,
stateSave: true,
fixedHeader: true,
pageLength: 50,
lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
processing: true,
ajax: '/script/exportMissingProductsClient.php',
columns: [
{data: 'EAN'},
{data: 'Vendor', className: 'editable'},
{data: 'Format'},
{data: 'Description'},
{data: 'Qty'},
{data: 'ExportPrice', className: 'editable'},
{data: 'BuyPrice'},
{data: 'Status'},
],
});
};
return {
//main function to initiate the module
init: function() {
initTable1();
},
};
}();
jQuery(document).ready(function() {
KTDatatablesDataSourceAjaxServer.init();
});
The problem I have is that not all data is passed to the update script.
If we take this sample data:
{"data":[{"EAN":"0801310970447 ","Vendor":"","Format":"PALADONE","Description":"FAST & FURIOUS 1970 DODGE CHARGER","Qty":17,"ExportPrice":"0,00\u20ac","BuyPrice":"9,00\u20ac","Status":""},{"EAN":"0801310976029 ","Vendor":"","Format":"PALADONE","Description":"FAST & FURIOUS 1995 TOYOTA SUPRA - ORANGE","Qty":20,"ExportPrice":"0,00\u20ac","BuyPrice":"9,00\u20ac","Status":""}]}
This is getting passed when editing the first line:
BuyPrice: ""
Description: "FAST & FURIOUS 1970 DODGE CHARGER"
EAN: "0801310970447 "
ExportPrice: "0,00€"
Qty: "17"
Status: ""
Vendor: "test"
So no Format, BuyPrice added...Format isn't even in the field list. Any idea why and how this is happening?
My debug code: https://debug.datatables.net/ugamoh
Thanks for all the help.
This question has an accepted answers - jump to answer
Answers
Format
isn't listed as one of yourfields
in the Editor config. So it won't be processed by the Editor.Kevin
And BuyPrice is specified as number which means that it's probably not submitting it because of the € sign....
I can't believe I missed Format not being there....just shows how you can waste time by being too detailed..
Its amazing how blind you can get to your code. A second set of eyes is always good :-)
Not sure but you might be correct.
Kevin