Return from many upload in table not editor

Return from many upload in table not editor

jhonny14jhonny14 Posts: 5Questions: 2Answers: 0

I used this code but it says: "TypeError: table.file(...) is undefined"

Any help is much apreciated.

{ data: "files",
render: function ( d ) {
for(index = 0; index < d.length; index++) {
return d ? table.file( 'files', d ).filename : 'No document';
}
}
}

This question has an accepted answers - jump to answer

Answers

  • jhonny14jhonny14 Posts: 5Questions: 2Answers: 0

    i have made it work with this:

    { data: "files", render: function ( data, type, full ) {
      return $.map( data, function ( d, i ) {
        return '<img alt="'+ d.filename +'" src="'+ d.web_path +'" width="24px"/>';
      } ).join( ' ' );
    }
    

    but i dont understand why with .each doesnt work

    { data: "files", render: function ( data, type, full ) {
      return $.each( data, function ( d, i ) {
        return '<img alt="'+ d.filename +'" src="'+ d.web_path +'" width="24px"/>';
      } );
    }
    
  • allanallan Posts: 63,204Questions: 1Answers: 10,415 Site admin
    Answer ✓

    I used this code but it says: "TypeError: table.file(...) is undefined"

    That would happen if you are using an old version of Editor or you used the $().dataTable() constructor rather than $().DataTable(). The file() method was introduced in Editor 1.5.

    The $.each method doesn't work, because $.each doesn't do anything with the return. The jQuery documentation says:

    The method returns its first argument, the object that was iterated.

    Allan

  • jhonny14jhonny14 Posts: 5Questions: 2Answers: 0

    so i am using: /*! DataTables Editor v1.5.4
    and the constructor: var table = $('#concesiune').DataTable( {

    .each method should return this:

     return '<img alt="'+ d.filename +'" src="'+ d.web_path +'" width="24px"/>';
    

    it should do for the lenght of data iterate and return the code above

    sorry for my poor knowledge

  • allanallan Posts: 63,204Questions: 1Answers: 10,415 Site admin

    Are you able to give me a link to the page so I can debug it it and see what is going on?

    Having said that, if the $.map method is working for you - go with that. That is a correct way to do it.

    Allan

This discussion has been closed.