Busy Dialog and Close

Hello,

I use the following code to show a Busy Dialog for Excel Export for a many rows because it needs some time:

protected async System.Threading.Tasks.Task btnAktionenClick(Radzen.Blazor.RadzenSplitButtonItem args)
{
dialogExport = await DialogService.OpenAsync("", ds =>
{
RenderFragment content = b =>
{
b.OpenElement(1, "img");
b.AddAttribute(2, "src", "/images/ajax-loader-kendo.gif");
b.AddAttribute(3, "style", "height:50px;width:50px;");
b.AddAttribute(4, "class", "mx-auto d-block");
b.CloseElement();
b.OpenElement(5, "div");
b.AddAttribute(6, "class", "row pt-3");
b.OpenElement(7, "div");
b.AddAttribute(8, "class", "col-md-12");
b.AddContent(9, "Daten werden exportiert...");
b.CloseElement();
b.CloseElement();
};
return content;
}, new DialogOptions() { ShowTitle = false, Style = "min-height:80px;min-width:150px;width:auto", CloseDialogOnEsc = false });
...

in the OnAfterRenderAsync I close this dialog

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await grid0.SelectRow(pfuscherakt.FirstOrDefault(), false);
}
DialogService.Close(dialogExport);

    }

the problem is that with that solution all other dialogs are also closed after Render - how to close only specific Dialogs?

robert

This method will close only the last opened dialog:

OK but use this in OnAfterRenderAsync it closes every dialog I open... but I want to close only the Busy Dialog which I opened in the "Export" click event...

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await grid0.SelectRow(pfuscherakt.FirstOrDefault(), false);
        }

        DialogService.Close(dialogExport);
    }

You need some condition. At the moment you are closing last dialog on every render.

OK - it might be good to have the possibility to close Dialogs with a ID or Name parameter...

DialogService.Close(null, "ExcelExport");

robert