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

Forums / Developing with Sitefinity / Custom DownloadList filter by date

Custom DownloadList filter by date

2 posts, 1 answered
  1. Anders Olsen
    Anders Olsen avatar
    9 posts
    Registered:
    28 May 2010
    02 Jun 2010
    Link to this post
    I created a custom DownloadList and I would like to add a new functionality to enable to filter by "", exactly only a year.
    I tried the way described here
    but I cannot apply it for "Upload date"

    Is there any different way to do it?


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Jun 2010
    Link to this post
    Hello Anders Olsen,

    You need to implement a custom |DownloadList control with a custom filter. There is no method that allows you to filter by a property. You can get the list of IContent items, then filter by DateCreated property and create an new list of filtered items that you will use to bind the control. You have to override CreateDataSource method of your custom control that inherits from DownloadList and filter the content there.

    sample code that filters all items by the current day. You could expose a public property that you will set from the ContentDesigner and control the filtering.

    protected override IList CreateDataSource()
         {
             IList items = base.CreateDataSource();
             IList filteredList =  new List<IContent>();
             if (items.Count > 0)
             {
                 foreach (IContent cnt in items)
                 {
                     if (cnt.DateCreated.Date == DateTime.Now.Date)
                     {
                         filteredList.Add(cnt);
                     }
                 }
             }
             return filteredList;
         }


    All the best,
    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.
    Answered
2 posts, 1 answered