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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Toast Dynamic Content Prob

Thread ID:

Created:

Updated:

Platform:

Replies:

146988 Aug 27,2019 07:16 PM UTC Dec 17,2020 02:42 PM UTC Blazor 16
loading
Tags: Toast
Raul
Asked On August 27, 2019 07:16 PM UTC

Hi, I have a problem with a toast which dynamically changes the message, when you first click the button to save the object, the toast displayed is empty, on second click it displays the dynamic message.
    
private async Task CreateVehicle()
    {

        try
        {
            TanCoLogisticsSDK.Vehicle result = await VCIJ.PostVehicleAsync(Vehicle);
            this.ToastTitle = "Success";
            this.ToastContent = "Saved";
            await Task.Delay(100);
            ToastObj.Show();
        }
        catch (Exception e)
        {
            this.ToastTitle = "Error";
            this.ToastContent = "Check and retry";
            await Task.Delay(100);
            ToastObj.Show();
        }

Pandiyaraj Muniyandi [Syncfusion]
Replied On August 28, 2019 11:25 AM UTC

Hi Raul, 
 
Greetings from Syncfusion support. 
 
We have validated your reported issue with shared code blocks and able to reproduce the issue from our end. The title and content variable are not updated in Toast model on update the variable dynamically until you call StateHasChanged method externally. 
 
So we suggest you to call StateHasChanged() method after title and content property values are updated like as follows 
 
 
private async Task CreateVehicle() 
    { 
        try 
        { 
            TanCoLogisticsSDK.Vehicle result = await VCIJ.PostVehicleAsync(Vehicle); 
            this.ToastTitle = "Success"; 
            this.ToastContent = "Saved"; 
            StateHasChanged(); 
            await Task.Delay(100); 
            ToastObj.Show(); 
        } 
        catch (Exception e) 
        { 
            this.ToastTitle = "Error"; 
            this.ToastContent = "Check and retry"; 
            await Task.Delay(100); 
            ToastObj.Show(); 
        } 
} 
 
 
 
We have prepared sample for your reference, get it from below link 
 
Regards, 
Pandiyaraj M 


Jacky
Replied On December 7, 2020 09:45 AM UTC

Hi ,

I use Syncfusion.Blazor 18.3.0.51 and refer above    Sample , but Content has no change .

My main procedures are below  :

Step1 : SfToast Component has define mapping attribute.


Step2 . Declare Contents use Array Variable


Step3 : Set the Break point durning Debug the program to view variable : 
Step 3.1 . Content variable value has been changed to this.ToastContent 
Step 3.2  Set  StateHasChanged()
Step 3.3  But check the Content property value of ToastObj has not changed

Best Regards !

Jacky



Indrajith Srinivasan [Syncfusion]
Replied On December 8, 2020 10:29 AM UTC

Hi Jacky, 
 
Greetings from Syncfusion support, 
 
We have validated you’re your reported query. We have tried to reproduce the reported issue and unfortunately we couldn’t find any issues with the SfToast. The ToastObj content is updated, after the Content property is changed dynamically. We have also shared the ensured sample from our end. 
 
 
Screenshot: