Exception error when returning fieldError for multi select field
Exception error when returning fieldError for multi select field
I've tried with both Editor 1.6.0 and 1.5.6 and get the following error when returning a fieldError for a multi select field:
dataTables.editor.min.js:80 Uncaught TypeError: Cannot read property 'error' of undefined(…)
This particular error was with 1.5.6. Even though I am using select2 I get the same with select. Adding and deleting work fine.
The main.Pub (not multi select) Editor field works as expected when returning the following fieldError:
fieldErrors: [{status: "Pub osv1pub is already assigned to OSV Cluster 1", name: "main.Pub"}]}
But when returning the below fieldError for main.Sub I receive the exception error:
{fieldErrors: [{status: "Sub bams3sub8 is already assigned to BAMS Cluster 3", name: "main.Sub"}]}
Do I need to configure something else for the multi select fields?
Kevin
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: '/manage_clusters',
table: '#edit-table',
fields: [
{ type: 'hidden', label: 'pkid:', name: 'main.pkid' },
{ label: 'Name:', name: 'main.name' },
{ type: 'select2', label: 'Contact Center:', name: 'main.fk_contact_centers', placeholder: 'Select a location' },
{ type: 'select2', label: 'Publisher:', name: 'main.Pub',
opts: { allowClear: true,
placeholder: 'Select a Publisher' }
},
{ type: 'select2', label: 'Subscribers:', name: 'main.Sub[]',
opts: { multiple: true,
placeholder: 'Select a Subscriber' }
},
{ type: 'select2', label: 'Music on Hold:', name: 'main.MOH[]',
opts: { multiple: true,
placeholder: 'Select a MoH Subscriber' }
},
{ type: 'select2', label: 'TFTP:', name: 'main.TFTP[]',
opts: { multiple: true,
placeholder: 'Select a TFTP Subscriber' }
},
]
} );
var table = $('#edit-table').DataTable( {
ajax: '/manage_clusters',
columns: [
{ data: 'main.pkid' },
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: 'main.name' },
{ data: 'cc.contact_center_name', editField: 'main.fk_contact_centers' },
{
data: 'cm.Pub',
render: function ( data, type, row ) {
if (data.length == 0) {
return null
} else {
return data[0].label
}
},
editField: 'main.Pub'
},
{
data: 'cm.Sub',
render: '[, ].label',
editField: 'main.Sub[]'
},
{
data: 'cm.MOH',
render: '[, ].label',
editField: 'main.MOH[]'
},
{
data: 'cm.TFTP',
render: '[, ].label',
editField: 'main.TFTP[]'
},
],
columnDefs: [
{ "targets": [0],
"visible": false,
"searchable": false
}
],
select: {
style: 'os',
selector: 'td:first-child'
},
} );
This question has an accepted answers - jump to answer
Answers
That error suggests that Editor isn't seeing the JSON for some reason. Could you give me a link to the page so I can debug it please.
Thanks,
Allan
Sorry Allan, I thought it was due to a change and it was but couldn't put my finger on it. Our discussion last week around multi select had me change
main.Sub
tomain.Sub[]
. I didn't add the[]
in my fieldError response. The problem was obvious once I read the Editor is not seeing the JSON.Its working now, thanks for all the hard work on this project!
Kevin
That would do it. Good to hear you've got it sorted out and working now!
Allan