This is a migrated thread and some comments may be shown as answers.

Pass Dynamic value into Save async declaration

1 Answer 317 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 14 Dec 2016, 04:48 PM

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?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 15 Dec 2016, 02:25 PM

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.
Tags
Upload
Asked by
Adam
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or