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

Forums / Developing with Sitefinity / DownloadList Group by Category

DownloadList Group by Category

8 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    18 Jun 2009
    Link to this post
    Hi there,

    I'm wondering if anyone has attempted this or if someone could point me in the right direction. I have a list template (user control) that the built in DownloadList points to using the ItemListTemplatePath property. I'm able to customize the look so data displays how I need it. The one thing I'm missing is that I want to have the repeater display items and group by the current category. I've done similar catagory grouping repeaters for other .net projects, just wire into the ItemDataBound. The issue i"m having is that I'm not able to find any examples of accessing data in the itemdatabound of the repeater. 
    I've tried dropping a label on the page that's called "Category" and this will display the category but it seems that it gets bound later because when I try to look at the value of Category.Text in my usercontrol it hasn't been set yet.

    Any help suggestions or other approaches would be greatly appreciated.

    Cheers,
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Jun 2009
    Link to this post
    Hi Phill Hodgkinson,

    1. The control supports FilterExpression that can be used to filter the items by category directly. The syntaxis is Category = "CategoryName". Another option is creating a custom logic using ObjectDataSource control (Then on odsImagesSelecting you can perform filtering or sorting) or overrding CreateDataSource() which R\retrieves content items from the data store with the specified filter.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Mar 2010
    Link to this post
    Ivan - is this done on the DownloadList.ascx external template or somewhere in the control you add to the page in Admin? I've looked in the advanced tab under the "Filters" section. Then in the item "FilterExpression". I put in what you said above where it now has "ParentID IN (c8d16b2c-7e04-45cb-b976-7750b38226b2)" in the text box and nothing worked.

    Am I missing something?

    Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Mar 2010
    Link to this post
    Hello Chip Gallent,

    ParentID means that you have selected a certain library from which you want to show images. You have to add Category = "SomeName" as suggestion in the previous post. By doing so the filter will match all items from your library that has been categorized with the specified category. If the list items do not match the one of the filter conditions you will not see any items displayed by the control.

    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.
  5. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Mar 2010
    Link to this post
    Ok - I got that. But it sounds like the filter is different than the title of the post. Is it possible to Order the download list within the control so you get something like this for Selected List "X":

    Category 1
    - Download 1
    - Download 2
    - Download 3
    Category 2
    - Download 4
    - Download 5
    - Download 6
    Category 3
    - Download 7
    - Download 8

    I need all of the selected docs in a download list grouped and then listed with their category.

    Thanks again!
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Mar 2010
    Link to this post
    Hi Chip Gallent,

    The control has a Sort property in the same section where FilterExpression property resides.

    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.
  7. Chip Gallent
    Chip Gallent avatar
    41 posts
    Registered:
    06 Nov 2009
    24 Mar 2010
    Link to this post
    Two things - 1) when I put CategoryName in there I get invalid Column Name as a error.

    2) If that works, how then do I get the control to loop through and put the Category Name within the listings at the top of each item group list like I listed above?

    Thanks again, Ivan.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Mar 2010
    Link to this post
    Hello Chip Gallent,

    I am not sure what is CategoryName.

    The syntax FOR FILTERING is Category = "HERE TYPE THE CATEGORY NAME USED FOR FILTERING"
    The syntax FOR SORTING is only by metakey - say : Author ASC

    The control cannot returns you the following structure out of the box


    Category 1
    - Download 1
    - Download 2
    - Download 3
    Category 2
    - Download 4
    - Download 5
    - Download 6
    Category 3
    - Download 7
    - Download 8

    This is a grouping - you group downloads by category name . By default the control will return a list of items filtered or sorted by a criteria. If you want to perform grouping you  need to create a completely new custom control or control that extends the default one - DownloadList.
    In the template you need to have two nested Repeater controls. One will be responsible for displaying the Category name ( Cagegory1, Cateogory2, Category 3) , since the other repeater will show the items that are inside each category. You need to bind the first repeater to all categories for the Provider that have items. Then get all items for each category and bind the second provider.

    sample

    var cntManager = new ContentManager("Libraries");
    var alItems = cntManager.GetContent();
     
    IList<string> categoryNames = new List<string>();
    foreach (IContent cnt in alItems)
    {
        string category = (string)cnt.GetMetaData("Category");
        if (!String.IsNullOrEmpty(category))
        {
             
            categoryNames.Add(category);
            // now you have a list of all available categories
            // and you have to bind the firs repeater to this list
            // The bind the second repeater use GetContent method and its overloads
          
        }
     
    }



    Useful link - finding content items

    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.
Register for webinar
8 posts, 0 answered