Assign ItemsParentId from encapsulated control
I have added the DownloadListView to a user control, because I need a way to use this control wherein the selected library is set dynamically.
I had hoped to simply put the following code in either the Page_Load or Page_PreRender handlers of the code behind:
downloadListView.MasterViewDefinition.ItemsParentId = DynamicallyDetermineParentId();
Hi Gary,
Yes. Your assumptions are correct. However, it might just be wholly easier to use our API to just create your own widget at that point. The DownloadList isn't incredibly complex if you need just one or two views and it will give you more control over everything.
Getting all documents is as easy as:
public
static
IQueryable<Document> GetDocumentsByDocumentLibraryFluentAPI(Guid documentLibraryId)
return
App.WorkWith().DocumentLibrary(documentLibraryId).Documents().Where(d => d.Status == ContentLifecycleStatus.Live).Get();
Thank you, Patrick. I came to the same conclusion, although I implemented it as a straightforward user control. Your approach to create a Sitefinity "Widget" instead of a user control is interesting. Is the advantage of this approach, that I would have been the ability to create a custom designer and also apply different rendering templates?
Regards,
Gary
Hi Gary,
A Sitefinity widget is essentially a user or custom control that gets registered in the toolbox. The benefit of a widget over just using it as a typically control is that you do get the designer which would allow you to implement specific configurations, change them on the fly, etc. If you build your widget as an ASP.NET custom control then you can take advantage of setting different templates. Here's the documentation.
I hope this helps.