@oliver-aldrian

@oliver-aldrian

Forum Replies Created

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • in reply to: find a specific row in a grid #103241
    oliver.aldrian
    Participant

    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!

    in reply to: find a specific row in a grid #103239
    oliver.aldrian
    Participant

    okay, 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?

    in reply to: find a specific row in a grid #103237
    oliver.aldrian
    Participant

    ok, 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.

    in reply to: find a specific row in a grid #103234
    oliver.aldrian
    Participant

    But 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.

    in reply to: Browser Context Menu surpression on DataGrid #103229
    oliver.aldrian
    Participant

    Thanks for the fast reply. Don’t mind me asking, but what is the time horizon for the next version?

    KR

    in reply to: find a specific row in a grid #103216
    oliver.aldrian
    Participant

    I 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();
    }
    }
    1. I don’t have the index of the row I want to select, I have the object that is displayed in the row
    2. 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.

    in reply to: find a specific row in a grid #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 1 year, 11 months ago by oliver.aldrian. Reason: typo
    in reply to: find a specific row in a grid #103167
    oliver.aldrian
    Participant

    Unfortunately 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?

    in reply to: find a specific row in a grid #103161
    oliver.aldrian
    Participant

    Hi,

     

    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

    in reply to: Changing color scheme of datagrid #103151
    oliver.aldrian
    Participant

    Thanks for the fast answer!

Viewing 10 posts - 16 through 25 (of 25 total)