@oliver-aldrian
@oliver-aldrian
Forum Replies Created
-
AuthorPosts
-
oliver.aldrianParticipant
ok, so this is then a bit finnicky to handle. when there are filter applied to the grid, I would have to apply the same filters to the datasource, to get the correct rowNumber.
TBH that could be handled better by the grid and the docs to the grid.
Anyway, thanks for the support!
oliver.aldrianParticipantokay, so the grid takes the data structure I feed in and I can simply check against the datastructure, and get the Id out of it. Good.
How does this work with preapplied filters? are the rows still in there but not visible, or are they removed from the grid?
oliver.aldrianParticipantok, so the grid does not support it natively to select something if I don’t have the Id ie. rowNumber.
I could work around that, iterate over the rows get the details, and compare them to the elements in my list, to get the correct row number.BUT as I already described: When the OnReady fires, grid.Rows is still empty even though I can clearly see the rows in the browser.
oliver.aldrianParticipantBut I want to select a row… and if there are no rows in the grid, how can I select one???
can you at least confirm that following statement is correct?
grid.SelectRows(projects.Where(x => x.Id.Equals(selectedProjectId)));
with projects being a List<Project> and Project being a class in my project.
oliver.aldrianParticipantThanks for the fast reply. Don’t mind me asking, but what is the time horizon for the next version?
KR
oliver.aldrianParticipantI have
<Grid @ref="grid" OnCellClick="CellClicked" OnReady="(x) => GridReady(x)" DataSource="@projects"> <Columns> <Column DataField="Id" Label="" Visible="false" AllowEdit="false" AllowSelect="false" /> <Column DataField="Name" Label="Name" AllowEdit="false" AllowSelect="false" /> </Columns> </Grid>
and
private async void GridReady(Grid grid) { var selectedProjectId = await LocalStorage.GetItemAsync("SelectedProject"); if (!selectedProjectId.Equals(Guid.Empty) && projects.Any(x => x.Id.Equals(selectedProjectId))) { grid.SelectRows(projects.Where(x => x.Id.Equals(selectedProjectId))); } else { ClearSelection(); } }
- I don’t have the index of the row I want to select, I have the object that is displayed in the row
- Setting a breakpoint into the GridReady Method I can see the page and grid load in the browser and can clearly see the entries in the grid. BUT grid.Rows is STILL EMPTY in this method.
Additional information: I am on Blazor .NET6 WebAssebmly and use the latest smart.Blazor version that nuget suggested.
oliver.aldrianParticipantHm… 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 inOnInitializedAsync
grid is still null, and persons did not arrive either (SignalR does need a bit). Then I moved it toOnAfterRender
but there thegrid.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, 6 months ago by oliver.aldrian. Reason: typo
oliver.aldrianParticipantUnfortunately this is not what I need to do.
I need the row id of an element where I have the value of an identifying column.
I have a grid with entries, where I want to preselect a row on page load, and to my knowledge grid.selectRow only does take an id.
Or is the id in the grid always the same as in the dataRecords object? But what if I have applied filtering and sorting?
oliver.aldrianParticipantHi,
having the same problem/taks (find rowId of certain data id value) with the grid in the smart.blazor framework.
Could you also help out with bit of code?
KR Oliver
oliver.aldrianParticipantThanks for the fast answer!
-
AuthorPosts