Access parent or child items in dynamic widget views

Out of the box dynamic content widgets provide you with intuitive helper methods for working with hierarchical content types. Using these simple helper methods, you can display the parent and child items of the hierarchical content types in the widget views.

Access child items

To access the child items of dynamic content object, you use the ChildItems helper method inside the detail templates of the widget.

NOTE:  The ChildItems helper method works only with dynamic content types that have parent-child hierarchy structure, and the Model is of type ItemViewModel. If you are using a custom widget to display the dynamic content items, make sure your Model inherits from Telerik.Sitefinity.Frontend.Mvc.Models.ItemViewModel.

This method returns a collection of the ItemViewModel type. As a result, you can access the properties of the child items using the following code:

List mode:

Details mode:

NOTE: Keep in mind that a parent item may have numerous child items, whereas child items have just one parent item. Consequently, in the code above, you need to specify the ChildType1 since there may be more than one child types.

Access parent items

To access the parent item of dynamic content object, you use the following helper method inside the detail templates of the widget:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Tags

Was this article helpful?