Hi,
I have seen Form - Auto-Generated sample in Blazor which is nice and handy, but what should I do, if I need to define a Dynamic event by code for a dropdown change for example ?
I might need to define and handle an event for each control that is dynamically generated. I hope someone can help.
Regards
We believe there can be use for an "OnUpdate" event on the form and you can Follow that here: https://feedback.telerik.com/blazor/1508940-add-onupdate-event. At the moment, I am marking this as a duplicate to it, and if a discussion here comes up with a different scenario/requirement/feature, we can discuss that as needed.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Ali,
What you are referring to is no longer an autogenerated form, but something you need to customize through the FormItems feature and their Templates. A list of countries is not a data source that the form could generate on its own anyway - it would generate a dropdown for enums (see more here).
My colleague Ed made a sample for you on adding custom editors with custom data source and event handling in your Twitter thread here. You can extend it to add the desired logic.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Thanks sir,
Let me make myself a bit more clear. Please look this example : https://demos.telerik.com/blazor-ui/form/auto-generated
Imagine Need to define 2 Dropdown and 3 TxtBox dynamically the then define an event for one of the Dropdowns which shows a list of countries and when the user selected "UK" 2 other controls should be disabled or hidden !.
Is this possible now ?. If yes, is there any sample ?
Hello Ali,
I can see a few options and I'd appreciate your thoughts on them so we can see how you imagine such an event:
It is important to keep in mind that exposing a ValueChanged event would mean that the form can no longer use two-way binding, which would kind of defeat its purpose - in Blazor the <Parameter> and <Parameter>Changed are the pair that produces two way binding and you cannot use them together (you can read more here). So, even ignoring the technical complexity of exposing that, it would rather destroy the Form component itself.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.