Custom Download List Widget Not Showing Document Images
I created a custom widget for the Download List with documents. My only issue is that the thumbnails aren't working...
I created this user control in my SitefinityWebApp using folder UserControls
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AdministrativeDocumentsFormsList.ascx.cs" Inherits="SitefinityWebApp.UserControls.AdministrativeDocumentsFormsList" %>
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<sitefinity:ResourceLinks id="resourcesLinks2" runat="server" Theme="Default">
<sitefinity:ResourceFile Name="Telerik.Sitefinity.Resources.Themes.Basic.Styles.icons.css" Static="true" />
</sitefinity:ResourceLinks>
<telerik:RadGrid id="documentsGrid" runat="server"
CssClass="sfdownloadTable sfTableMode"
skin="Sitefinity" AutoGenerateColumns="false" OnItemDataBound="documentsGrid_ItemDataBound">
<ClientSettings EnableRowHoverStyle="false" EnableAlternatingItems="false" />
<PagerStyle Mode="NumericPages" />
<MasterTableView PageSize="50" EnableNoRecordsTemplate="true">
<Columns>
<telerik:GridBoundColumn UniqueName="title" HeaderText="<%$ Resources:Labels, File %>" DataField="Title" ItemStyle-CssClass="sfdownloadTitle" HeaderStyle-CssClass="sfdownloadTitle" />
<telerik:GridBoundColumn UniqueName="description" HeaderText="<%$ Resources:Labels, Description %>" DataField="Description" ItemStyle-CssClass="sfdownloadDescription" HeaderStyle-CssClass="sfdownloadDescription" />
<telerik:GridTemplateColumn
UniqueName="templateColumn"
HeaderText="<%$ Resources:Labels, Download %>"
ItemStyle-CssClass="sfdownloadCell" HeaderStyle-CssClass="sfdownloadCell" >
<ItemTemplate>
<sitefinity:SitefinityHyperLink ID="documentLink" runat="server" Text="<%$ Resources:Labels, Download %>" CssClass="sfdownloadLink" target="_blank" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<NoRecordsTemplate>No documents found!</NoRecordsTemplate>
</MasterTableView>
</telerik:RadGrid>
I am not sure if a reference is off (maybe to the icons css)... or if my itemdatabound logic is...but any help would be great...
in my code behind, this is in my itemdatabound. I assumed that "ThumbnailURL" would correspond to the hyperlink image url but when i view in page it is invalid.
SitefinityHyperLink link = dataItem["templateColumn"].FindControl("documentLink") as SitefinityHyperLink;
Document documentItem = (Document)e.Item.DataItem;
if (link != null)
link.ToolTip = documentItem.Description;
link.NavigateUrl = documentItem.MediaUrl;
link.ImageUrl = documentItem.ThumbnailUrl;
link.Text = documentItem.Title;
my data source is simply tied to the list from App.WorkWith()
.DocumentLibrary(parentLibrary.Id)
.Documents()
.Where(d => d.Status == ContentLifecycleStatus.Live)
.Get().ToList();
I attached a photo that shows the standard grid on top of the custom grid. obviously mine isn't working the greatest yet.
Thanks
Hello Dustin,
Thumbnails can be added to document items, but there is no authomatic code for generation when you upload an image to a document. This is why you couldn't access the thumbnailUrl - simply documents don't have thumbnails by default (as you can see by yourself in the sf_media_thumbnails table of teh database) As a workaround, I would suggest you to either use Image Libraries or use teh MediaUrl property of the documents and set the height and width of the items with css.
All the best,I finally figured this out... in my css class for the radgrid i had to add css class "sfHasIcons" and in my code behind on my item databind i had to set the css class for each document type
dataItem["templateColumn"].CssClass = "sf" + document.Extension.Replace(".", "");
Hi Dustin,
Thank you for sharing your implementation with the community!
Regards,