How to refresh the progress bar in a grid column when resizing in Blazor Progress Bar?
This article explains how to refresh the progress bar in a grid column when resizing in Blazor Progress Bar.
Refresh the Progress Bar in a Grid Column When Resizing
Blazor Progress Bar provides an option to refresh the progress bar in a grid column when resizing.
To refresh the progress bar inside the grid column when resizing, you need to call the RefreshAsync method for the progress bar’s instance in the Grid’s ResizeStopped event.
The below code example demonstrates how to refresh the progress bar in a grid column when resizing.
Index.razor
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.ProgressBar
<SfGrid DataSource="@ListOfValues" AllowResizing="true">
<GridEvents ResizeStopped="ResizeStoppedHanlder" TValue="ProgressBarValues"></GridEvents>
<GridColumns>
<GridColumn Field="@nameof(ProgressBarValues.Progress)" HeaderText="Progress">
<Template>
@{
var prog = (context as ProgressBarValues).Progress;
<SfProgressBar @ref=SfProgressBars[Count] Value="@prog" Minimum="0" Maximum="100" Height="15" ShowProgressValue="true" />
Count++;
}
</Template>
</GridColumn>
<GridColumn Field="@nameof(ProgressBarValues.Id)" HeaderText="ID"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public List<ProgressBarValues> ListOfValues { get; set; }
public List<SfProgressBar> SfProgressBars { get; set; } = new List<SfProgressBar>();
public int Count { get; set; } = 0;
protected override void OnInitialized()
{
ListOfValues = Enumerable.Range(1, 75).Select(x => new ProgressBarValues()
{
Id = 1000 + x,
Progress = new Random().Next(100),
}).ToList();
for (int i = 0; i < ListOfValues.Count + 1; i++)
{
SfProgressBars.Add(new SfProgressBar());
}
}
public void ResizeStoppedHanlder(ResizeArgs args)
{
foreach (var SfProgressBar in SfProgressBars)
{
_= SfProgressBar.RefreshAsync();
}
}
public class ProgressBarValues
{
public int Id { get; set; }
public int Progress { get; set; }
}
}
The following screenshot illustrates the output of the code snippet.
Live Sample for Refreshing the Progress Bar in a Grid Column When Resizing
Conclusion
I hope you enjoyed learning how to refresh the progress bar in a grid column when resizing.
You can refer to our Blazor Progress Bar feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Progress Bar to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!