Filtering data dynamic data

Posted by Community Admin on 04-Aug-2018 08:33

Filtering data dynamic data

All Replies

Posted by Community Admin on 13-Aug-2012 00:00

Hi

I am trying to retrieve a list of module contents and filter on a specific field.

The code I currently have which appears to pull all the published items back looks like this.

01.DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
02.                Type mclEventType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.McLEvents.MclEvent");
03. 
04.                var theitems =
05.                    dynamicModuleManager.GetDataItems(mclEventType).Where(
06.                        s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
07.                 
08.                grdFuture.DataSource = theitems;
09.                grdFuture.DataBind();

I think I need to add another where clause to the expression, but I can't seem to. 

Any suggestions gratefully received.

David Bigg

Posted by Community Admin on 16-Aug-2012 00:00

Hello,

To filter based on a certain field use GetValue  followed by the field name you want to get. To use GetValue() add reference to Telerik.Sitefinity.Model.

using Telerik.Sitefinity.Model;
 
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                Type mclEventType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.McLEvents.MclEvent");
  
                var theitems =
                    dynamicModuleManager.GetDataItems(mclEventType).Where(
                        s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && s.GetValue("Title") == "Item1");
                  
                grdFuture.DataSource = theitems;
                grdFuture.DataBind();
                


Greetings,
Stanislav Velikov
the Telerik team
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

Posted by Community Admin on 16-Aug-2012 00:00

Hi Stanislav

Thanks for your reply, that was exactly what I needed. It is all filtering nicely now.

Regards,
David Bigg

This thread is closed