1.6.2 Editor select regression
1.6.2 Editor select regression
vipsoft
Posts: 10Questions: 1Answers: 0
Upgrading to 1.6.2, the inline editor fails on click. Getting:
Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11
Code snippet:
var editor;
var acquirers;
$(document).ready(function() {
$('table.records_list').DataTable({
ajax: {
url: '/acquirers.json',
dataSrc: function (json) {
acquirers = json.options._acquirer;
return json.data;
}
},
paging: false,
info: false,
columns: [
{
data: '_acquirer.name',
editField: 'acquirer',
defaultContent: ''
},
],
initComplete: function (settings, json) {
$(document).trigger('initComplete.dt');
}
});
});
$(document).on('initComplete.dt', function () {
editor = new $.fn.dataTable.Editor({
ajax: '/acquirers.json',
table: 'table.records_list',
formOptions: {
main: {
submit: 'changed'
}
},
fields: [
{
label: 'Acquirer',
data: 'acquirer',
name: 'acquirer.id',
type: 'select',
options: acquirers,
placeholder: '',
placeholderDisabled: false
}
]
});
$('table.records_list').on('click', 'tbody td:not(".no-inline-edit")', function () {
editor.inline(this, {
onBlur: 'submit'
});
});
});
JSON payload:
{"data":[{"id":1,"acquirer":2,"_acquirer":{"name":"Bravo","id":2},"DT_RowId":"row_1"}],"options":{"_acquirer":[{"value":1,"label":"Alpha"},{"value":2,"label":"Bravo"},{"value":3,"label":"Charlie"}]},"files":[]}
Test URLs
* 1.6.1: https://aegisapi.com/1.6.1/
* 1.6.2: https://aegisapi.com/1.6.2/
This discussion has been closed.
Replies
Nevermind. Just read the changelog. =P
I changed:
editField: 'acquirer',
toeditField: 'acquirer.id',
Thanks for the update. I should perhaps have highlighted that change a little more. In the majority of cases the
fields.name
andfields.data
attributes are the same, but if they are different and you are also usingcolumns.editField
then yes, it would need a change in your code.Allan