datatable-with-uploadmany-uncaught-exception-unknown-file-table-name

datatable-with-uploadmany-uncaught-exception-unknown-file-table-name

sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0

Hey allan
im trying to implement uploadMany,
->implemented add successfully with ajax.,but got issue with edit ,please see the below error

uncaught exception: Unknown file table name: propertyImages
code:
{
label: "Images:",
name: "propertyImages[].imageId",
type: "uploadMany",
ajax: 'propertyImage/add',
display: function(imageId, counter) {
return '<img src="' + propertyEditor.file('propertyImages', imageId).imagePath + '"/>';
},
noFileText: 'No images'
}

json data
for the table:

{
    "draw": 1,
    "recordsTotal": 3,
    "recordsFiltered": 3,
    "data": [{
      "propertyId": 7,
      "propertyFacing": "EAST",
      "active": "Active",
      "propertyImages": [{
        "imageId": 1,
        "imageName": "NO_IMAGE",
        "imageType": "jpeg",
        "imageSize": 0,
        "imagePat": "/propertyImages/NO_IMAGE"
       }]
}

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    That's the same error and issue as your other thread on this topic.

    You don't have a files object in your JSON response, so using file() isn't going to be able to find anything.

    Allan

  • sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0
    edited July 2018

    Hey I created fresh ticket if I can get support from others, I had actually asked question how modify json on client side ?.
    I tried with datasrc and data but no luck
    {

        "draw": 1,

        "recordsTotal": 1,

        "recordsFiltered": 1,

        "data": [{

            "propertyId": 1,

           ....

            "propertyImages": [ ... ]

        }],

        "error": null,

        "files": {

            "propertyImages": {

                "1": {

                    "fileId": 1,

                    "imageName": "p1.jpg",

                    "imageType": null,

                    "imageSize": 226347,

                    "imagePath": "src/main/resources/static/propertyImages/p1.jpg"

                }

            }

        }

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Answer ✓

    If you need to modify the JSON returned from the server, you could use the dataFilter option of the jQuery.ajax function. In there you would JSON.prase() the text response from the server, modify it as you need and then JSON.stringify() it for return.

    Allan

  • sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0

    hey allan

    thanks alot, it worked as expected now. no error when i modified json as u suggested in dataFilter.
    -> next step, how to call the delete in edit->upload many? im able to call ajax for adding images in edit , but when clicked on delete button no response..

    thanks
    sarath

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Answer ✓

    It doesn't make an Ajax call when you click the X icon. It simply removes the reference of the image from the current array.

    Allan

This discussion has been closed.