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
close icon

Toast Dynamic Content Prob

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();
        }

16 Replies

PM Pandiyaraj Muniyandi Syncfusion Team 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 



JA Jacky 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




IS Indrajith Srinivasan Syncfusion Team 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:  
 
 
 
Can you please check the above shared sample, and let us know if it meets your issue reproducing scenario ? 
 
Regards, 
Indrajith 



JA Jacky December 9, 2020 03:25 AM UTC

Hi Indrajith  ,

Thank you for your sample which can work.
But my program is  SfTreeView  Target SfContextMenu on ItemSelected  to popup a dialog , after confirm to Trigger Task  Run Toast.Show().  
Thus sometimes can work and somtimes can’t.

Is it affected by this reason ? 
And the ToastObj always stays at previous set Title and Content Values.

Regards!

Jacky






JA Jacky replied to Jacky December 9, 2020 03:51 AM UTC

Hi Indrajith  ,

Thank you for your sample which can work.
But my program is  SfTreeView  Target SfContextMenu on ItemSelected  to popup a dialog , after confirm to Trigger Task  Run Toast.Show().  
Thus sometimes can work and somtimes can’t.

Is it affected by this reason ? 
And the ToastObj always stays at previous set Title and Content Values.

Regards!

Jacky





Attach my code as below , Thanks! 

Attachment: MIS126_TreeView_b267ec06.zip


IS Indrajith Srinivasan Syncfusion Team December 9, 2020 08:43 AM UTC

Hi Jacky, 
 
We have validated your reported query. Yes, the Task.run creates an impact with the toast content update. It prevents the further updates until the task is done, hence the SfToast content is not updated. Later once the Task is completed, the SfToast content is updated properly. 
 
 
Regards, 
Indrajith 



JA Jacky December 10, 2020 02:43 AM UTC

Hi Indrajith ,

I try not to use Task Run and use the same way on ContxtMenu and TreeView Dragdrop to call Toast.
But Dragdrop Event not work as belows pictures :

Thanks for help again!


Jacky

ContxtMenu -->work

Dragdrop --> not work



IS Indrajith Srinivasan Syncfusion Team December 10, 2020 06:49 AM UTC

Hi Jacky,  
 
We have checked the shared screenshots. With the working scenario MenuSelect, there is not Task.run used. We could see Task.run code, in the nodeDagSecUser method. Can you try removing it and check the reported issue ? 
 
Highlighted the Task.run specified in the nodeDragSecUser: 
 
 
 
Regards, 
Indrajith 



JA Jacky December 10, 2020 10:05 AM UTC

Hi Indrajith  ,

Thank you for your help.
I  removed the Task.Run()  and debug the value (this.ToastContent and ToastObj.Content)  still not the same.

Regards!

Jacky



IS Indrajith Srinivasan Syncfusion Team December 11, 2020 06:44 AM UTC

Hi Jacky, 
 
Good day to you, 
 
We have further validated on the reported issue. Can you try updating the Toast content, inside an asyn Task call function instead of async void. Check the below code blocks and sample for reference. 
 
 
Code blocks:  
 
 
@using Syncfusion.Blazor.Navigations 
 
@using Syncfusion.Blazor.Notifications 
 
<SfToast @ref="ToastObj" Title="Adaptive Tiles Meeting" Timeout=5000 Icon="e-meeting" Content="@ToastContent"> 
    <ToastPosition X="Right"></ToastPosition> 
</SfToast> 
 
<SfTreeView TValue="TeamDetails" AllowDragAndDrop="true"> 
    <TreeViewEvents TValue="TeamDetails" NodeDropped="@NodeDragSecUser"></TreeViewEvents> 
    <TreeViewFieldsSettings TValue="TeamDetails" Id="Id" Text="Name" Child="Children" DataSource="@Team" Expanded="Expanded"></TreeViewFieldsSettings> 
</SfTreeView> 
 
@code{ 
    SfToast ToastObj; 
 
    private string ToastContent { get; set; } = ""; 
    private string[] Contents = new string[] { 
        "Content 1", 
        "Content 2", 
        "Content 3", 
        "Content 4" 
    }; 
    public class TeamDetails 
    { 
        public string Id { get; set; } 
        public string Name { get; set; } 
        public bool Expanded { get; set; } 
        public bool Selected { get; set; } 
        public List<TeamDetails> Children; 
    } 
    List<TeamDetails> Team = new List<TeamDetails>(); 
 
    protected override void OnInitialized() 
    { 
        base.OnInitialized(); 
        List<TeamDetails> EmployeeDetails = new List<TeamDetails>(); 
        Team.Add(new TeamDetails 
        { 
            Id = "01", 
            Name = "ASP.NET MVC Team", 
            Expanded = true, 
            Children = EmployeeDetails, 
        }); 
        EmployeeDetails.Add(new TeamDetails 
        { 
            Id = "01-01", 
            Name = "Smith", 
        }); 
        EmployeeDetails.Add(new TeamDetails 
        { 
            Id = "01-02", 
            Name = "Johnson", 
        }); 
        EmployeeDetails.Add(new TeamDetails 
        { 
            Id = "01-03", 
            Name = "Anderson" 
        }); 
 
        List<TeamDetails> EmployeeDetails1 = new List<TeamDetails>(); 
 
        Team.Add(new TeamDetails 
        { 
            Id = "02", 
            Name = "Windows Team", 
            Children = EmployeeDetails1, 
        }); 
        EmployeeDetails1.Add(new TeamDetails 
        { 
            Id = "02-01", 
            Name = "Clark" 
        }); 
        EmployeeDetails1.Add(new TeamDetails 
        { 
            Id = "02-02", 
            Name = "Wright" 
        }); 
 
        List<TeamDetails> EmployeeDetails2 = new List<TeamDetails>(); 
 
        Team.Add(new TeamDetails 
        { 
            Id = "03", 
            Name = "Web Team", 
            Children = EmployeeDetails2, 
        }); 
        EmployeeDetails2.Add(new TeamDetails 
        { 
            Id = "03-01", 
            Name = "Joshua" 
        }); 
        EmployeeDetails2.Add(new TeamDetails 
        { 
            Id = "03-02", 
            Name = "Matthew" 
        }); 
    } 
 
    public async Task NodeDragSecUser(DragAndDropEventArgs args) 
    { 
        this.ToastContent = this.Contents[0]; 
        await Task.Delay(100); 
        await this.ToastObj.Show(); 
    } 
} 
 
 
Please let us know if the solution helps, 
 
Regards, 
Indrajith 



JA Jacky December 14, 2020 04:24 AM UTC

Hi Indrajith ,

I check the same code structure , your sample is workable .
I dynamic change my content , but "this.ToastObj Content" always does not change ,  don't know why ?

Attach file my code.

Regards !

Jacky



Attachment: MIS126_TreeView_42bb9539.zip


IS Indrajith Srinivasan Syncfusion Team December 14, 2020 12:49 PM UTC

Hi Jacky, 
 
We have tried to make an runnable sample using the shared code blocks, but we have faced many issue when configuring in a separate sample. Since the reported issue occurs only with your sample configurations. 
 
Can you replicate the issue in the above shared sample and revert back to us ?. So that we can validate and provide solution at earliest. 
 
Regards, 
Indrajith 



JA Jacky December 15, 2020 03:06 AM UTC

Hi Indrajith ,

I attached the program code and database, and also wrote a simple description of the demand problem.
Thank you for your assistance.

Regards!

Jacky

Attachment: SystemLead.Project.LK.Server.BZSWeb_6a180f07.zip


IS Indrajith Srinivasan Syncfusion Team December 15, 2020 11:02 AM UTC

Hi Jacky, 
 
Thanks for sharing the sample, 
 
We have checked the shared sample and documentation. Have faced the below exception, after the sample is being launched. Do i need to make any changes, related to the sample configurations to resolve the reported issue ? 
 
Followed the below steps to run the sample: 
 
  • Run the Lk.sln file.
  • Once the packages are restored launched the sample.
  • Faced the below issue.
 
 
 
Regards, 
Indrajith 



JA Jacky December 16, 2020 03:12 AM UTC

Hi Indrajith ,

Sorry, it needs to be imported into the database before the entire problem can be reproduced.
I will reattach the description file as follows.

Regards!

Jacky

Attachment: Sample_ReadMe_658b22ec.zip


IS Indrajith Srinivasan Syncfusion Team December 17, 2020 02:42 PM UTC

Hi Jacky, 
 
We have created a new incident under your Direct trac account to follow up with this query. We suggest you to follow up with the incident for further updates. Please log in using the below link.  
 
 
Regards, 
Indrajith 


Loader.
Live Chat Icon For mobile
Up arrow icon