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

Forums / General Discussions / Download List: Grouping by List Name

Download List: Grouping by List Name

10 posts, 0 answered
  1. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    16 Feb 2010
    Link to this post
    Hi,
    I am using Sitefinity download list module in my website.
    In one section, I want to display multiple document lists and I want to group those documents list name wise.
    Means 1st List name then all the documents from that list then 2nd list name and so on...
    How can I achieve this?


    --Thanx
    Shraddha.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hi shraddha,

    Thank you for using our servicex.

    I have prepared a blog post explaining the steps you have to take to achieve this: Donwload List control to group items for download by parent library.


    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    19 Feb 2010
    Link to this post
    Hi,
    Thanx for the reply. I have tried the same thing and its working properly.
    Only thing left now is, I want to sort that display by LibraryName desc. How can I achieve that?

    --Thanx
    Shraddha
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 Feb 2010
    Link to this post
    Hi shraddha,

    I have updated the blog post to to allow sorting options for the libraries. You can check it out there.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    16 Jun 2010
    Link to this post
    Hi,
    Thanx for the help.
    My Libraries are getting sorted now by Name but now I want to sort Library items by DocumentDate(custom field for library items) desc. How can I achieve this??
    I am using CustomDocumentList control as given below.
    public class CustomDownloadList : ContentView
    {
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/Libraries/CustomDonwloadList.ascx";
            }
            set
            {
                base.ItemListTemplatePath = value;
            }
        }
        public override string ProviderName
        {
            get
            {
                return "Libraries";
            }
            set
            {
                base.ProviderName = value;
            }
        }
        protected override void CreateContentList()
        {
            ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
            libraryManager = new LibraryManager();
            IList libraries = null;
            Guid[] parentIds = filterBuilder.ParseParentsFilter();
            if (parentIds.Count() > 0)
            {
                List<ILibrary> libs = new List<ILibrary>();
                foreach (Guid id in parentIds)
                {
                    libs.Add(libraryManager.GetLibrary(id));
                }
                libraries = libs.ToList();
            }
            else
            {
                libraries = libraryManager.GetAllLibraries("Image", false);
            }
            //sort libraries in ascendding order by name
            IQueryable<ILibrary> librariesQ = libraries.Cast<ILibrary>().AsQueryable<ILibrary>();
            var sortedLibraries = from list in librariesQ
                                  orderby list.Name descending
                                  select list;
            LibrariesRepeater.ItemDataBound += new RepeaterItemEventHandler(LibrariesRepeater_ItemDataBound);
            LibrariesRepeater.DataSource = sortedLibraries.ToList();
            LibrariesRepeater.DataBind();
        }
        void LibrariesRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                ILibrary library = (ILibrary)e.Item.DataItem;
                if (library.ItemsCount > 0)
                {
                    Literal LibraryName = (Literal)e.Item.FindControl("LibraryName");
                    Repeater ItemsRepeater = (Repeater)e.Item.FindControl("itemsRepeater");
                    if (ItemsRepeater != null && LibraryName != null)
                    {
                        LibraryName.Text = library.Name;
                        IList items = library.GetItems();
                        ItemsRepeater.ItemDataBound += new RepeaterItemEventHandler(ItemsRepeater_ItemDataBound);
                        ItemsRepeater.DataSource = items;
                        ItemsRepeater.DataBind();
                    }
                }
                  
            }
        }
        void ItemsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                HyperLink DownloadLink = (HyperLink)e.Item.FindControl("DownloadLink");
                Literal Title = (Literal)e.Item.FindControl("Title");
                Literal Description = (Literal)e.Item.FindControl("Description");
                Literal Extension = (Literal)e.Item.FindControl("Extension");
                Label Author = (Label)e.Item.FindControl("Author");
                Literal UploadDate = (Literal)e.Item.FindControl("UploadDate");
                Literal Size = (Literal)e.Item.FindControl("Size");
                Repeater Tags = (Repeater)e.Item.FindControl("Tags");
                HyperLink FileFileDownloadLink = (HyperLink)e.Item.FindControl("FileDownloadLink");
                IContent contentItem = (IContent)e.Item.DataItem;
                if (contentItem.MimeType.StartsWith("Video", true, CultureInfo.InvariantCulture))
                {
                    DownloadLink.NavigateUrl = base.ResolveUrl(string.Format("{0}?download=true", contentItem.UrlWithExtension));
                }
                else
                {
                    DownloadLink.NavigateUrl = base.ResolveUrl(contentItem.UrlWithExtension);
                }
                FileFileDownloadLink.NavigateUrl = base.ResolveUrl(string.Format("{0}?download=true", contentItem.UrlWithExtension));
                Title.Text = contentItem.GetMetaData("Name") as string;
                Description.Text = contentItem.GetMetaData("Description") as string;
                Extension.Text = contentItem.GetMetaData("Extension") as string;
                Author.Text = contentItem.GetMetaData("Author") as string;
                UploadDate.Text = contentItem.DateCreated.ToShortDateString();
                Size.Text = contentItem.GetMetaData("Size").ToString();
                long num;
                long.TryParse(Size.Text, out num);
                Size.Text = LibraryHelper.FormatSizeString(num);
                Tags.ItemDataBound += new RepeaterItemEventHandler(Tags_ItemDataBound);
                Tags.DataSource = libraryManager.GetTags(contentItem.ID);
                Tags.DataBind();
            }
        }
        void Tags_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                ITag dataItem = (ITag)e.Item.DataItem;
                HyperLink link = (HyperLink)e.Item.FindControl("tagLink");
                if (link != null)
                {
                    link.Text = dataItem.TagName;
                    link.NavigateUrl = this.GetTagUrl(dataItem, this.ItemListUrl);
                }
            }
        }
        public Repeater LibrariesRepeater
        {
            get
            {
                return base.ListContainer.GetControl<Repeater>("librariesRepeater", false, Telerik.Framework.Web.TraverseMethod.BreadthFirst);
            }
            set
            {
                LibrariesRepeater = value;
            }
        }
        private LibraryManager libraryManager;
    }


    --Thanx
    Shraddha
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Jun 2010
    Link to this post
    Hi shraddha,

    You can try this code to get items:
    if (ItemsRepeater != null && LibraryName != null)
    {
        LibraryName.Text = library.Name;
        IList items = libraryManager.GetContent(0, 0, "DocumentDate DESC", library.ID);
        ItemsRepeater.ItemDataBound += new RepeaterItemEventHandler(ItemsRepeater_ItemDataBound);
        ItemsRepeater.DataSource = items;
        ItemsRepeater.DataBind();
    }


    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    20 Oct 2010
    Link to this post
    Can I just set the default sort somewhere in ControlTemplates/Libraries/DownloadListControlDesigner.ascx?
    ...
    I did create a custom control that call the class CustomDownloadList.cs but in it is IList items = library.GetItems();

    I replaced this line:
    IList items = library.GetItems();

    With
    IList items = library.GetContent(0, 0, "Ordinal ASC", library.ID);

    And it throws an error.

    thanks.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Oct 2010
    Link to this post
    Hello Laura,

    There is a SortExpression property under Filters section that you can use to filter the list by a metakey.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    20 Oct 2010
    Link to this post
    We are creating a site that will be a type of document repository. We all thier documents are stored in libraries. I am using the standard download list control mapping to a custom template to display the library on the page.  There are many many pages/libraries. 

    What I would like to achieve is for the user to just be able to drag and drop the download list control on the page and select the library.  I would like the display mode (table) and the default ordering already in place programatically so that they don't have to make the choices and expecially not have to go into the properites of the designer.  These are not web savvy folks. As a bonus it would be cool to just just display libraries based on thier roles but I know that would entail something more complicated and I know it is coming out in 4.0 (?). Can't wait!

    Thank you for any suggestions!
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Oct 2010
    Link to this post
    Hi Laura,

    You can create a custom control that inherit from DownloadList and override its public properties - for instance SortExpresion. Depending on the current users' role ( UserManager.GetCurrentUserRoles())you can set the value of SortExpression property.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
10 posts, 0 answered