This blog provides the show notes for our August 19, 2021, webinar, “Working with Blazor DynamicComponent and 2021 Volume 2 Blazor Updates.” The webinar was presented and hosted by Syncfusion Product Manager Uma Maheswari Chandrabose. The Q & A portion of the webinar is at the end of the blog. If you missed the webinar or would like to watch it again, please see our YouTube channel or watch it here.
In this webinar, we showed how to render Syncfusion Blazor components dynamically using the DynamicComponent, a new, built-in Blazor component. With it, you can easily specify the component type and pass the required parameters using a dictionary. To depict the working of DynamicComponent, we placed a dropdown list with two options in this example: Employee Details and Meeting Schedules. When Employee Details is chosen, the Blazor DataGrid component is dynamically rendered, whereas choosing Meeting Schedules renders the Blazor Scheduler component dynamically.
· Legend support added.
To review, in this webinar we covered DynamicComponent in Blazor and how to best utilize it. Also, we’ll take a look at the new updates added to Essential Studio® for Blazor in our 2021 Volume 2 release.
We hope you enjoyed this webinar and please keep an eye out for our future Syncfusion webinars.
Q: Hey, thanks for a great presentation. Is the DynamicComponent much faster than using, say, an if statement in the Razor?
A: We have internally checked this scenario and detected a very minor difference in speed between rendering the DynamicComponent and rendering the components directly inside an “if” statement. Mostly, we can say the DynamicComponent is one of the simplest and cleanest approaches to rendering Blazor components dynamically as it avoids the need for multiple iterations through type-checks. Although you can use complex conditions, render fragments, use reflection, or render a builder tree to iterate through your components, it becomes hard to deal with complex parameter passing. So, the DynamicComponent simply helps in rendering the components specified by type and parameters and speeds up the working of applications by segregating the complex code.
Q: Can you make a DynamicComponent using OData?
A: Yes, it is possible to create a DynamicComponent in Blazor that uses OData services. Say, for example, you can bind data to the Blazor DataGrid from an OData service using the Syncfusion DataManager component. Then, you can render it dynamically by passing the component type to the DynamicComponent in the index.razor page. You can refer to this Github example, where you need to uncomment the commented lines to see the working of how the data will be retrieved from the OData service and bound to the DataGrid that renders dynamically.