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