Blazor Grid - Selection - Grid Selected Items Inicialization #1127
Unanswered
rjmoreno2022
asked this question in
Q&A
Replies: 1 comment
-
For the Grid attribute Data make the value a call to a method. Let's call it GetData(). Then in GetData once you have the list of your particular TItem you can use the reference to the grid and access the SelectedItems and add each of the TItem that should be checked. It may not be the most elegant way to do it, but at least it works. `private void List< TItem > GetData()
}` |
Beta Was this translation helpful? Give feedback.
0 replies
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