WASM Radzen Datagrid RowSelect event fires before the selected row binding has been 'bound' #583

Closed
opened 2026-01-29 17:39:44 +00:00 by claunia · 2 comments
Owner

Originally created by @RFIsoft on GitHub (Oct 18, 2022).

Radzen Datagrid in WASM:
The RowSelect event fires before the selected row binding has been 'bound'

Expected:
On RowSelect event, bounded selected property to represent selected row
Actual:
On RowSelect, bounded selected property represents previous selected row.

Workaround: use property setter (which is sync only...)

To check/reproduce: implement a property setter (on rowselect bind) and event method (on rowselect event), and print the 'trigger'

//In RadzenDataGrid, use 
@bind-Value="@SelectedTenants"
RowSelect="@TenantSelected"

//in @code:
private IList<TenantDto> _selectedTenants = new List<TenantDto>();
    IList<TenantDto> SelectedTenants 
    {
        get
        {
            return _selectedTenants;    
        }
        set
        {
            _selectedTenants = value;
            var id = SelectedTenants[0].Id;
           //This will print after the Event Callback
            Console.WriteLine($"Selected tenant PROP: {id} {SelectedTenants[0].Name}");
        }
    }
   private async Task<EventCallback> TenantSelected()
    {
        var id = SelectedTenants[0].Id;
        //this will print before the property binding)
        Console.WriteLine($"Selected tenant CallBack: {id} {SelectedTenants[0].Name}");
}
Originally created by @RFIsoft on GitHub (Oct 18, 2022). Radzen Datagrid in WASM: The RowSelect event fires before the selected row binding has been 'bound' Expected: On RowSelect event, bounded selected property to represent selected row Actual: On RowSelect, bounded selected property represents previous selected row. Workaround: use property setter (which is sync only...) To check/reproduce: implement a property setter (on rowselect bind) and event method (on rowselect event), and print the 'trigger' ``` //In RadzenDataGrid, use @bind-Value="@SelectedTenants" RowSelect="@TenantSelected" //in @code: private IList<TenantDto> _selectedTenants = new List<TenantDto>(); IList<TenantDto> SelectedTenants { get { return _selectedTenants; } set { _selectedTenants = value; var id = SelectedTenants[0].Id; //This will print after the Event Callback Console.WriteLine($"Selected tenant PROP: {id} {SelectedTenants[0].Name}"); } } private async Task<EventCallback> TenantSelected() { var id = SelectedTenants[0].Id; //this will print before the property binding) Console.WriteLine($"Selected tenant CallBack: {id} {SelectedTenants[0].Name}"); } ```
Author
Owner

@enchev commented on GitHub (Oct 18, 2022):

Hey @RFIsoft,

You can use the argument of the event to get the selected row.

@enchev commented on GitHub (Oct 18, 2022): Hey @RFIsoft, You can use the argument of the event to get the selected row.
Author
Owner

@RFIsoft commented on GitHub (Oct 18, 2022):

Thanks @enchev Did not realize the event included that..... That's indeed the preferred solution!
Pete

@RFIsoft commented on GitHub (Oct 18, 2022): Thanks @enchev Did not realize the event included that..... That's indeed the preferred solution! Pete
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#583