Duplicated
Last Updated: 25 Apr 2022 11:01 by ADMIN
Created by: Douglas
Comments: 3
Category: Notification
Type: Feature Request
5

I have utilized the Notification component in a centralized portion of my mainlayout and created a service so that all notifications flow through control so I don't have to repeat a TelerikNotification  component on every content page.    It is working great except..  there is no API control over the notifications once they are created.

What I would like to do is have all the open notifications cleared in response to a location change event on the NavigationManager.  I can accomplish the event but cant clear the notifications.

 

Thx

---

ADMIN EDIT

Here is a workaround - hide the notification component so it disposes and hides all notification popups, then show it again so you can keep using it:

<TelerikButton OnClick="@AddNotifications">Add success, info, warning, error notification</TelerikButton>

<TelerikButton OnClick="@HideAllNotifications">Hide all notifications</TelerikButton>

@if (isNotificationRendered) 
{ 
    <TelerikNotification @ref="@NotificationReference" Class="MyTelerikNotification"></TelerikNotification>
}

@code {
    //hide all implementation
    bool isNotificationRendered { get; set; } = true;
    async Task HideAllNotifications()
    {
        isNotificationRendered = false;
        await InvokeAsync(StateHasChanged);
        await Task.Delay(20);
        isNotificationRendered = true;
    }
    //end


    public TelerikNotification NotificationReference { get; set; }

    public void AddNotifications()
    {
        // Success
        NotificationReference.Show(new NotificationModel()
        {
            ThemeColor = ThemeColors.Success,
            Text = "Success",
        });

        // Info
        NotificationReference.Show(new NotificationModel()
        {
            ThemeColor = ThemeColors.Info,
            Text = "Info",
        });

        // Warning
        NotificationReference.Show(new NotificationModel()
        {
            ThemeColor = ThemeColors.Warning,
            Text = "Warning",
        });

        // Error
        NotificationReference.Show(new NotificationModel()
        {
            ThemeColor = ThemeColors.Error,
            Text = "Error",
        });
    }
}

<style>
    .MyTelerikNotification .k-notification-container .k-notification-wrap {
        width: 300px;
        height: 50px;
        font-size: 1.5em;
        text-align: center;
        align-items: center;
    }
</style>

---