Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
How can i add file upload control in grid
posted

Hi,

I want to add file upload control for each line in grid which will return the path for that specific line.

can you tell me how to do it.

Thanks

Sushant

Parents
  • 37874
    posted

    Hello Sushant,

    A possible approach would be to place the upload in an unbound column with template containing a container element, like a div:

    { headerText: "Upload", unbound: "true", key: "Upload", template: "<div class='upload'></div>" }

    Then, on rowsRendered event you can initialize the igUpload. On fileUploaded you can set the value of another grid cell to the uploaded file path.

     

    Code Snippet
    1. rowsRendered: function () {
    2.     $(".upload").each(function (i, e) {
    3.         this.id = "upload" + i;
    4.         $(this).igUpload({
    5.             fileUploaded: function (evt, ui) {
    6.                 var idx = $("#grid").igGrid("activeRow").id;
    7.                 $('#grid').igGridUpdating('setCellValue', idx, "ImageUrl", ui.filePath);
    8.             },
    9.             mode: "single",
    10.             autostartupload: true,
    11.             // to upload a file, you need a server-side handler
    12.             progressUrl: "/IGUploadStatusHandler.ashx",
    13.             controlId: "serverID"
    14.         });
    15.     });
    16. }


    Please feel free to contact me if you have any further questions.

Reply Children