$.fn.datatable.editor is not a constructor
$.fn.datatable.editor is not a constructor
Hi all,
This seems to be a well discussed error, but I've not been able to resolve it.
"$.fn.datatable.editor is not a constructor"
I have these references to js and css.
script src="js/datatable-editor/datatables.js"></script
script src="js/datatable-editor/dataTables.editor.js"></script
script src="js/datatable-editor/editor.bootstrap.js"></script
script src="js/datatable-editor/editor.bootstrap4.js"></script
script src="js/datatable-editor/editor.foundation.js"></script
script src="js/datatable-editor/editor.jqueryui.editor.js"></script
script src="js/datatable-editor/editor.semanticui.js"></script
<link rel="stylesheet" type="text/css" href="css/datatable-editor/datatables.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.bootstrap4.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.foundation.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.jqueryui.css"/>
<link rel="stylesheet" type="text/css" href="css/datatable-editor/editor.semanticui.css"/>
I am initially just trying to initialise as described in this article - https://editor.datatables.net/manual/getting-started
var editor;
$(document).ready(function () { editor = new $.fn.dataTable.Editor({}); });
Any advice would be greatly appreciated!
Thanks,
Lewis
This question has an accepted answers - jump to answer
Answers
You haven't shown your references to js.
You only listed CSS includes. Are you including
dataTables.editor.js
?Plus you are loading CSS files for many different styling libraries (bootstrap, jqueryui, ec). Which are you using? You only want to load for that one library.
You can try the Download Builder to help get the correct JS and CSS include files for Datatables and Editor.
Kevin
Apologies, the js was excluded from my post. They're there now that I've removed the < and >.
I'll reduce the css references, thanks for the advice.
A reference to jQuery js should precede your other js references.
The same goes for the JS references.
The Editor is loaded locally on your server. Make sure the paths are correct and the at files are being loaed.
Kevin
There are no errors when running the code in the attached screenshot. So is the initialisation described in this article no longer supported?
https://editor.datatables.net/examples/inline-editing/simple
Thanks,
Lewis
Maybe the order you are loading the scripts in your page?
ITs hard to say whats going on in your page without seeing it in action. Can you post a link to your page or a test case showing the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks for the feedback.
I've now gone an alternative route with my code, so I'm past the initial error.
However, I am now receiving this (also well documented error).
Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11
Based on the points in the article, I've played around with the fields defined for my datatable and editor but with no success. Is anyone able to suggest what the correct field setup would be for the Editor based on what I have in the DataTable fields?
var qualifications = [];
Hi Kevin,
I've uploaded a test case, it's showing the initial error that I was getting though.
http://live.datatables.net/yesurumi/1/edit?html,js,console,output
Any input would be great, thanks.
Lewis
There were a few things to fix in your test case:
";
) in thetable
that were at the end of some linesdata
option from both Editor and Datatables. In Datatables this cleared the table since the variable is blankHere is the updated example:
http://live.datatables.net/yesurumi/3/edit
I have found for inline editing to work each row needs filed with a unique ID. not sure you have one with the data you have so e I added one. I used
idSrc
in the Editor config to map to the ID column. Now inline editing works.Kevin
Thanks so much for this Kevin, it's a massive help. Thank you for your time.
Lewis