I have a component that is accessed via SfMenu MenuItem but is used in several workflows off the same menu tree. The menu uses the Url attribute and the workflow is changed via the parameter being passed in. The problem is that the page view does not update. In a normal case, I'd use an onclick event and navigation manager with force set to true or in others workflow changes StateHasChanged().
What is the best way to accomplish this using the SfMenu -> MenuItem?
Thanks
Mike
@page "/fetchdata"
@page "/fetchdata/{CurrentCount:int}"
@using BlazorApp_ServerSide.Data
@inject WeatherForecastService ForecastService
@using Syncfusion.Blazor.Buttons
@inject NavigationManager Navigation
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
if (CurrentCount < Count)
{
CurrentCount++;
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
<td><SfButton Content="Redirect" @onclick="Redirect"></SfButton></td>
</tr>
}
}
</tbody>
</table>
}
@code {
private WeatherForecast[] forecasts;
[Parameter]
public int CurrentCount { get; set; } = 0;
private int Count = 5;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (CurrentCount != 0)
{
Count = 5;
}
}
private void Redirect()
{
Count = 2;
CurrentCount = 0;
Navigation.NavigateTo("/FetchData/1");
}
}
|