Blazor Grid - Selection - Grid Selected Items Inicialization #1127
Unanswered
rjmoreno2022
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How would I initialize selected items from my Blazor Bootstrap Grid?
Grid:
<Grid @ref="gridSoporte"
TItem="InfoSoporte"
Class="table table-hover table-bordered table-striped"
Data="lSoporte"
AllowSorting = "true"
SelectionMode="GridSelectionMode.Multiple"
SelectedItemsChanged="OnSelectedItemsChanged"
SelectedItems="@selectedItemsInicial"
AllowSelection="true"
Responsive="true">
...
Method to try inicialization:
private async Task InicializarSeleccionados()
{
try
{
selectedItemsList = new List(); //This List has items
selectedItemsInicial = new HashSet();
if (lSoporte.Any())
{
selectedItemsList = lSoporte.FindAll(x => x.IsSelected).ToList();
selectedItemsList.ForEach(x => selectedItemsInicial.Add(x));
}
await gridSoporte.RefreshDataAsync();
StateHasChanged();
}
catch (Exception e)
{
await MessageSwalService.ShowMessageSwal(e.Message, MessageSwalService.TipoMensajeSwal.Danger);
}
}
Beta Was this translation helpful? Give feedback.
All reactions