Standalone Editor file upload error
Standalone Editor file upload error
Hello
While using datatable Editor in standalone mode, I'm receiving javascript error: TypeMismatchError, File: dataTables.editor.js, Line: 4140, Column: 2
This is the last line of Editor.upload = function..., which reads:
reader.readAsDataURL( files[0] );
Following is the editor implementation:
$(document).ready(function() {
feditor = new $.fn.dataTable.Editor( {
ajax: {
url: "./putFile",
data:function ( d ) {
return $.extend( {}, d, {
"recID": feditor.field( 'recID' ).val(),
"recLstID": feditor.field( 'recLstID' ).val(),
"recUser": feditor.field( 'recUser' ).val()
} );
}
},
fields: [{
label: "File:",
name: "fileData",
type: "upload",
display: function (file_id) {
return file_id;
},
dragDrop: false,
{
name: "recID",
type: "hidden"
},
{
name: "recLstID",
type: "hidden"
},
{
name: "recUser",
type: "hidden"
}
],
bServerSide: false
});
}
file_id shows up in display window after upload, however the error above is stopping the execution and "Uploading file" button doesn't go away.
The jdom I receive from my servlet (java) is following:
{
"file": {
"artifact": {
"X0000000000003": {
"web_path": "/upload/testfile.txt",
"filename": "testfile.txt"
}
}
},
"upload": {
"id": "X0000000000003",
"recID": "0000000000003",
"recLstID": "1003280",
"fileName": "testfile.txt"
}
}
Thank you in advance!
Answers
Sorry, forgot to start from telling that error happens during file upload.
Thank you,
Taras
Hi Taras,
Interesting - i don't think I've come across that error before. Can you give me a link to the page showing the issue so I can check it out please?
Thanks,
Allan
Allan,
I will try to arrange this, but app is inside corporate intranet. Major POINT: this works in Chrome without issues and throws an error in IE11 (even set to Edge compatibility). It happens on second pass of the method when File object is null.
I think I found related post: https://datatables.net/forums/discussion/38742
However I use DataTables Editor v1.6.3. This IE compatibility issue doesn't seem to be resolved yet or Microsoft broke something again. In either way, this is a major project impact for us.
Thank you,
Taras
Allan,
More investigation led me to believe that issue lies in file back read, where editor tries to display it back. This works well with editor working with images and datatable. Is it possible to disable this read back in editor code?
ALSO - I do not get this error in IE in ver. 10 compatibility mode, only in Edge. IE10 doesn't try to call eader.readAsDataURL( files[0] ); method second time with "files" being null.
Could you clarify what you mean by "read back" - do you mean the display of the image in the input? If so, use the
display
property of theupload
field type and set it to justreturn ' ';
or similar.Allan
I'm actually returning file_id, but it still seem to trigger javascript call with null value in IE11 and above.
If you are able to send me a link to the page that would be awesome. You can send me a PM by clicking my forum user name above and the "Send message".
Thanks,
Allan
Cannot send link as this app is on corporate servers
Taras
Can you use JSFiddle, http://live.datatables.net or similar to create a test case so I can offer some help?
Allan