We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to clear only success messages

Hi,

It is possible to clear all file entries from by using ClearAllAsync method
https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfUploader.html#Syncfusion_Blazor_Inputs_SfUploader_ClearAllAsync

Is there a way to clear only success messages from the list, but not removing error messages and the files still  waiting in the upload queue?

Thanks & Kind regards


3 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team May 5, 2023 09:20 AM UTC

Hi Yunus,

Query 1: It is possible to clear all file entries from by using ClearAllAsync method:

We cannot clear the file entries in the saved location when called the clearAllAsync method we can clear only the rendered file list of the uploader component.

Query 2: Is there a way to clear only success messages from the list, but not removing error messages and the files still  waiting in the upload queue?

We have achieved your requirement by using the JSIntrop.

Find the code example here:

[index.razor]

<div class="target">

 

<SfUploader @ref="uploadObj" ID="UploadFiles" AutoUpload="false" DropArea=".target">

    <UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove"></UploaderAsyncSettings>

    <UploaderEvents Success="OnSuccess" ></UploaderEvents>

</SfUploader>

</div>

@code

{

    SfUploader uploadObj;

 

    [Inject]

    protected IJSRuntime JsRuntime { get; set; }

 

 

    public string customHeader { get; set; } = "";

 

    public void OnSuccess(Syncfusion.Blazor.Inputs.SuccessEventArgs args)

    {

       JsRuntime.InvokeVoidAsync("onListClear", args);

    }

}


[RemoveFileList.js]

window.onListClear = (id) => {

    var fileListElement = document.querySelectorAll(".e-upload-file-list");

    for (var count = 0; count <= fileListElement.length; count++) {

        var fileNameList = fileListElement[count].getAttribute("data-file-name");

        if (fileNameList === id.file.name) {

            fileListElement[count].remove();

        }

    }

}

 

Find the sample in the attachment:

Regards,

Sureshkumar P


Attachment: Blazor_Upload_App_76302f97.zip

Marked as answer

YU Yunus May 8, 2023 08:54 AM UTC

Hi  Sureshkumar,
Thanks for the offered solution. It works great.

Kind regards



UD UdhayaKumar Duraisamy Syncfusion Team May 9, 2023 05:04 AM UTC

We are glad the suggestion helped you to achieve your requirement. Please let us know if you need further assistance. 


Loader.
Up arrow icon