Unplanned
Last Updated: 22 Sep 2021 05:22 by ADMIN
Alan
Created on: 08 Jul 2020 06:51
Category: Upload
Type: Feature Request
16
Trigger File Select dialog from my own button

I would like to have my users click my own button or element to trigger the file select dialog that you get from clicking the "Select Files..." button on the Upload component.

A workaround is to use a function like this

window.customUploadClick = function () {
    $('.k-upload-button input').trigger('click');
}

---

ADMIN EDIT

If you are not using jQuery already, you don't have to add it for this, standard browser API can do this too:

@inject IJSRuntime _js

<script suppress-error="BL9992">
    window.customUploadClick = function () {
        document.querySelector(".k-upload-button input").click();
    }
</script>

<TelerikButton OnClick="@InvokeSelectClick">invoke click</TelerikButton>

<TelerikUpload></TelerikUpload>

@code{
    async Task InvokeSelectClick()
    {
        await _js.InvokeVoidAsync("customUploadClick");
    }
}

---

0 comments