+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Download List Widget Not Showing Document Images

Custom Download List Widget Not Showing Document Images

4 posts, 1 answered
  1. Dustin
    Dustin avatar
    20 posts
    Registered:
    05 Jan 2012
    20 Mar 2013
    Link to this post
    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
  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    25 Mar 2013
    Link to this post
    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,
    Jen Peleva
    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
  3. Dustin
    Dustin avatar
    20 posts
    Registered:
    05 Jan 2012
    28 Mar 2013 in reply to Jen Peleva
    Link to this post
    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(".", "");
    Answered
  4. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    01 Apr 2013
    Link to this post
    Hi Dustin,

    Thank you for sharing your implementation with the community! 

    Regards,
    Jen Peleva
    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
4 posts, 1 answered