Filter Releated DynamicContent

Posted by Community Admin on 04-Aug-2018 11:06

Filter Releated DynamicContent

All Replies

Posted by Community Admin on 03-Sep-2013 00:00

Hi
I'am stroggling with this Query that should list colors in a dropdownlist. The colors are selected on a product and are stored in a releated table. All seem to Work fine exept for the filtered Collection. Anyone have an iden??
Many thanks in advance :-)))

Public Function GetColorDataItems() As IQueryable(Of DynamicContent)
 
    ' Fetch a collection of "live" and "visible" color items that is selected / conained in the current Product
    Dim dynamicModuleManager As DynamicModuleManager = dynamicModuleManager.GetManager()
 
    'Get the Type for the Color
    Dim FarveType As Type = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Produkter.Farve")
 
    'Set the product Guid
    Dim Productguid As Guid = New Guid(Me.hdnProductId.Value) '("2f0bcd28-a68f-6507-ad29-ff00003013e0")
 
    'Get the Product item as DynamicContent
    Dim produktItem As DynamicContent = RetrieveProduktByID(Productguid)
 
    'Get at list of Guid's that are selected on the product
    Dim assignedColors = produktItem.GetValue(Of TrackedList(Of Guid))("Farve")
 
    'Get a collection of all the colors based on each selected guid (assignedColors)
    Dim FilteredCollection = dynamicModuleManager.GetDataItems(FarveType).Where(Function(i) i.GetValue(Of TrackedList(Of Guid))("Farver").Contains(assignedColors))
 
    Return myFilteredCollection
End Function

Posted by Community Admin on 04-Sep-2013 00:00

Hi Again
I found a solution written by Vasilev in May 2013, where he actualy have written how to first get alle the itemsid guid from the current record and then filter releated content from other types. If anyone needs this is here: http://www.sitefinity.com/blogs/veselin-vasilev-blog/2013/05/29/working-with-related-dynamic-content-items-in-sitefinity

Best regards
Henrik

Posted by Community Admin on 04-Sep-2013 00:00

Hello Henrik,

I am glad you've found the solution described by Veselin. This is the recommended way to work with related items.

Regards,
Slavo
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed