Getting a dynamic collection
I have the code snippet from the backend to get a collection of my module item, but it's returning my 8 results instead of the 4 I see in the backend.
...unless I call a .Distinct(), then I get my 4 back
Any idea what the problem might be?
public
void
OnRotator_NeedsDataSource(
object
sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type rotatorItemType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.Rotator.RotatorItem"
);
// This is how we get the collection of Rotator Item items
var items = dynamicModuleManager.GetDataItems(rotatorItemType);
var data = (from r
in
items.ToList()
select
new
Image1 = r.GetValue(
"Image1"
),
Image2 = r.GetValue(
"Image2"
),
SlideUrl = r.GetValue(
"SlideUrl"
),
SliderText = r.GetValue(
"SliderText"
),
Index = r.GetValue(
"Index"
)
);
((RadListView)sender).DataSource = data.Distinct().OrderBy(x => x.Index);
Hello Steve,
Most likely you're also getting the master copies of the items, can you please try filtering for the Live status and items that are Visible like this:
var items = dynamicModuleManager.GetDataItems(rotatorItemType).Where(di => di.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && di.Visible ==
true
);