Assign ItemsParentId from encapsulated control

Posted by Community Admin on 04-Aug-2018 01:58

Assign ItemsParentId from encapsulated control

All Replies

Posted by Community Admin on 23-Mar-2013 00:00

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();

However, the assignment seems to be ignored. 

Attempting to analyze the source code makes me think that the MasterViewDefinition is loaded and processed from within CreateChildControls.  If that is the case, then I would never have an opportunity to override a property in the MasterViewDefinition. I then presume that the only way to make this work is to sub-class DownloadListView, override CreateChildControls, re-implement the method body with the same source code of the original, with the addition of setting the above mentioned property before calling this.LoadView(viewName).

Is that the only way to solve this problem?

Thanks,
Gary

Posted by Community Admin on 27-Mar-2013 00:00

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();

Add to the .Where() filter and you'll be able to just filter by library dynamically. You can then just bind it to a grid/listview and get the same result with more control than the document list view widget. You can create a designer in a few clicks with Thunder to sort the library.

Kind regards,
Patrick Dunn
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 28-Mar-2013 00:00

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

Posted by Community Admin on 29-Mar-2013 00:00

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.

All the best,
Patrick Dunn
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

This thread is closed