Pass Dynamic value into Save async declaration

2 posts, 0 answers
  1. Adam
    Adam avatar
    1 posts
    Member since:
    Jun 2016

    Posted 14 Dec 2016 Link to this post

    Hi there,

    I need to pass an upload point into the path to be able to successfully post my files:

    @(Html.Kendo().Upload()
                      .Name("file")
                      .Multiple(false)
                      .Events(e => e
                          .Error("onError")
                          .Success("onSuccess")
                          .Select("onSelect")
                      )
                      .Async(a => a
                          .Save("UploadFile", "Storage", new { uploadpoint = "4FE69113-B190-49B4-ADDC-EB2371C6119A" })
                          .Batch(false)
                          .AutoUpload(true)
                      )
                )

    I want to make the GUID dynamic based off the selected value of a dropdown. Is there any way to make that route param dynamic either using a function:

    new { uploadpoint = GetUploadPoint() }

    Or by using javascript to read the selected value of my dropdown?

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2204 posts

    Posted 15 Dec 2016 Link to this post

    Hello Adam,

    You could achieve this by dynamically setting the async.saveUrl configuration property before each upload e.g. in the upload event handler.
    E.g.

    function onUpload(e) {
        //read DropDown value
     
        e.sender.options.async.saveUrl = <new save URL>;
    }

    Regards,
    Dimiter Madjarov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top