#103177
oliver.aldrian
Participant

Hm… I think I don’t understand…

 

I have a class

class Person{
Guid Id { get; set; }
string Name { get; set; }
}

and I have a page


@page "/persons"

@implements IAsyncDisposable

@code {

Grid grid;
private HubConnection? hubConnection;
private List persons;

protected override async Task OnInitializedAsync()
{
hubConnection = new HubConnectionBuilder()
.WithUrl(NavigationManager.ToAbsoluteUri("/datahub"))
.Build();

hubConnection.On<List>("ReceivePersons", async (persons) =>
{
this.persons = persons;
StateHasChanged();
});

await hubConnection.StartAsync();

await hubConnection.SendAsync("GetPersons");
}

public async ValueTask DisposeAsync()
{
if (hubConnection is not null)
{
await hubConnection.DisposeAsync();
}
}

An for some reason I want to select all rows that contain an entry with the name “Oliver” on page load.

How would I do that?

I tried grid.SelectRows(persons.Where(x => x.Name.Contains("Oliver"))) but in OnInitializedAsync grid is still null, and persons did not arrive either (SignalR does need a bit). Then I moved it to OnAfterRender but there the grid.Rows are still Empty even if they are already displayed in the browser.

Do you have an Idea / code snippet?

  • This reply was modified 2 years, 1 month ago by oliver.aldrian. Reason: typo