Standalone Editor file upload error

Standalone Editor file upload error

tarasivtarasiv Posts: 6Questions: 1Answers: 0

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

  • tarasivtarasiv Posts: 6Questions: 1Answers: 0

    Sorry, forgot to start from telling that error happens during file upload.

    Thank you,
    Taras

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    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

  • tarasivtarasiv Posts: 6Questions: 1Answers: 0

    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

  • tarasivtarasiv Posts: 6Questions: 1Answers: 0
    edited September 2017

    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.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Is it possible to disable this read back in editor code?

    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 the upload field type and set it to just return ' '; or similar.

    Allan

  • tarasivtarasiv Posts: 6Questions: 1Answers: 0

    I'm actually returning file_id, but it still seem to trigger javascript call with null value in IE11 and above.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    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

  • tarasivtarasiv Posts: 6Questions: 1Answers: 0

    Cannot send link as this app is on corporate servers

    Taras

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Can you use JSFiddle, http://live.datatables.net or similar to create a test case so I can offer some help?

    Allan

This discussion has been closed.