RadzenDropdownDataGrid: Component loses state if component is dynamically created #1274

Closed
opened 2026-01-29 17:51:27 +00:00 by claunia · 1 comment
Owner

Originally created by @bancroftway on GitHub (Jun 13, 2024).

When Radzendropdowndatagrid component is dynamically generated, it loses it's state when clicking outside the component. I have recorded a video showing the issue: https://youtu.be/k25OrXuhelc

Here is a reproduction: https://github.com/bancroftway/radzenbugrepro/tree/dropdowngriddynamiccontrols

OS: Windows 11
Browser: IE Edge (Chromium based)
Browser Version: 126.0.2592.53
Radzen.Blazor Version: 4.32.7

Originally created by @bancroftway on GitHub (Jun 13, 2024). When Radzendropdowndatagrid component is dynamically generated, it loses it's state when clicking outside the component. I have recorded a video showing the issue: https://youtu.be/k25OrXuhelc Here is a reproduction: https://github.com/bancroftway/radzenbugrepro/tree/dropdowngriddynamiccontrols OS: Windows 11 Browser: IE Edge (Chromium based) Browser Version: 126.0.2592.53 Radzen.Blazor Version: 4.32.7
Author
Owner

@enchev commented on GitHub (Jun 13, 2024):

Your component (EntityFilterCmp) will raise an EventCallback (SelectedEntitiesChanged) which is handled in the render of the page and this is causing the problem:
https://github.com/bancroftway/radzenbugrepro/blob/dropdowngriddynamiccontrols/Radzen-DropdownGrid-Issue-Repro/Client/Pages/Index.razor#L17

EventCallbacks in Blazor will automatically call StateHasChange() which will re-render your page - by simply removing the handler the problem will be "fixed":

image
image

To avoid this you either need to change how your page will create EntityFilterCmp (not in render for sure) or you can use simple Action instead EventCallback:
image
image
image

@enchev commented on GitHub (Jun 13, 2024): Your component (`EntityFilterCmp`) will raise an EventCallback (`SelectedEntitiesChanged`) which is handled in the render of the page and this is causing the problem: https://github.com/bancroftway/radzenbugrepro/blob/dropdowngriddynamiccontrols/Radzen-DropdownGrid-Issue-Repro/Client/Pages/Index.razor#L17 EventCallbacks in Blazor will automatically call StateHasChange() which will re-render your page - by simply removing the handler the problem will be "fixed": ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/0084eb3a-c984-4c67-be16-041ace795ed4) ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/76d58614-a670-4cdd-9c6e-d75ce9658ff7) To avoid this you either need to change how your page will create EntityFilterCmp (not in render for sure) or you can use simple Action instead EventCallback: ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/92e19b69-ad99-48f3-bcf2-638799767424) ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/be69af99-a7d3-44da-8470-7c3f0b74f497) ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/bd46f14b-e159-4853-a834-1bff712a61ab)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1274