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

Forums / General Discussions / Module Builder: sorting list items?

Module Builder: sorting list items?

12 posts, 0 answered
  1. SteveV
    SteveV avatar
    178 posts
    Registered:
    06 Nov 2011
    11 Jan 2012
    Link to this post
    I have created a Staff Biographies module using the new module builder (love it!).  I need to set the display order of the list items so I can display staff in the appropriate order (President, Executive Director, Clinical Directros, etc.).  I included a numeric field named SortOrder in my module hoping that I could use that for sorting. 

    After dropping the widget on a page and selecting the "List Settings" edit options, I can see a combobox labeled "Sort Staff Biographies" which has options for the following:

    Last published on top
    Last modified on top
    By Title (A-Z)
    By Title (Z-A)
    As set in Advanced mode

    When I click in the "Advanced" button in the widget edit window I see nothing that appears to be related to item sort order.  Am I missing something?

    --Steve
  2. Haroon
    Haroon avatar
    4 posts
    Registered:
    01 Dec 2011
    11 Jan 2012
    Link to this post
    Can any please, respond to this post, I am trying to order the items created in the modulebuilder .
    I've created 7 items .. Youth - Partners - Services - Research - Employee- Invlove - Contact
    I want to order them to be like .. Partners - Youth - Research ... etc..
    I want to change their order, but it doesn't depend on any thing like A-Z .. or Z-A .. no i want to choose the order with my self .. 4 example .I wanna be able to order those items the same way i order the pages ..
  3. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    11 Jan 2012
    Link to this post
    Hello,

     The "As Set in Advanced Mode" setting for the filtering is for the Filter Expression that you have exposed in the Advanced settings in the designer. You can access that from Advanced >> ControlDefinition >> Views >> FrontendList >> DynamicContentMasterView. The only other way to filter the items would be to create a custom control and then make queries using the generated code reference for the module and filter the collection by the fields you would like. Same counts for ordering - you can either set it with the SortExpression, found again in Advanced >> ControlDefinition >> Views >> FrontendList >> DynamicContentMasterView or create a control that orders the collection of the items.

    Kind regards,
    Svetoslav Petsov
    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. SteveV
    SteveV avatar
    178 posts
    Registered:
    06 Nov 2011
    11 Jan 2012
    Link to this post
    Hi Svetoslav,
    I ended up creating a custom control and doing some simple sorting like so:
    var myCollection = dynamicModuleManager.GetDataItems(staffBioType).Where(i => i.Status == ContentLifecycleStatus.Live).OrderBy(i => i.GetValue<decimal>("SortOrder"));

    While this works, it got me wondering how I'd do complex sorting.  Normally, I'd create a helper class that inherits from IComparer and handle the sorting in the class' Compare method implementation.  And  I'd use the collection's "ToList()" method to get a generic list that can be sorted using my comparer class.

    I tried doing this very thing but couldn't figure out how to extract my module's custom "SortOrder" property from the DynamicContent object passed in to the Compare method:
    public class StaffBioSorter : IComparer<DynamicContent>
    {
        public int Compare(DynamicContent x, DynamicContent y)
        {
        }
    }

    I'm sure I'm overlooking something very basic here.

    Thanks -- Steve
  5. Dimitar Dimitrov
    Dimitar Dimitrov avatar
    35 posts
    Registered:
    06 Dec 2016
    13 Jan 2012
    Link to this post
    Hi Steve,

    In the Compare method, you can use:
    var xSortOrder = x.GetValue<decimal>("SortOrder");
    var ySortOrder = y.GetValue<decimal>("SortOrder");
     and then compare them.

    You may need to add the following namespaces:
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.DynamicModules;
    using Telerik.Sitefinity.Data.Linq.Dynamic;
    using Telerik.Sitefinity.DynamicModules.Model;
    using Telerik.Sitefinity.Utilities.TypeConverters;



    Greetings,
    Dimitar Dimitrov
    Sitefinity 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
  6. SteveV
    SteveV avatar
    178 posts
    Registered:
    06 Nov 2011
    13 Jan 2012
    Link to this post
    Hi Dimitar,

    That's the first thing I tried but the DynamicContent class does not implement a GetValue method (see attached image)

    Steve
  7. Dimitar Dimitrov
    Dimitar Dimitrov avatar
    35 posts
    Registered:
    06 Dec 2016
    13 Jan 2012
    Link to this post
    Hello Steve,

    Have you added the namespaces, I've mentioned?

    Greetings,
    Dimitar Dimitrov
    Sitefinity 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
  8. SteveV
    SteveV avatar
    178 posts
    Registered:
    06 Nov 2011
    13 Jan 2012
    Link to this post
    Oops.  No, I missed the "Telerik.Sitefinity.Model" namespace--working fine now.

    Thanks,

    Steve
  9. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    20 Jun 2012
    Link to this post
    When using the "As Set in Advanced Mode" for sorting items, is there a way to specify a classification that's set to "Only one classification item can be selected" as the field to be sorted by, or would that require a custom control?
  10. Tony
    Tony avatar
    2 posts
    Registered:
    16 Jan 2009
    24 Apr 2013 in reply to Svetoslav Petsov
    Link to this post
    Svetoslav,

    We are currently using 5.4.  I looked for the settings path that you specified but am unable to find it in 5.4.  I did find Advanced >> ContentView >> Controls >> [[YourDynamicModule]] >> Views  and also Advanced >> DynamicModules >> Controls >> [[YourDynamicModule]] >> Views.  The former path does have a Sort Expression setting that works on the backend but I'm unable to find any settings that will control the frontend sort order.

    Is there an area that does allow you to set the sort order for the frontend without resorting to writing a custom ASCX?
  11. Tony
    Tony avatar
    2 posts
    Registered:
    16 Jan 2009
    24 Apr 2013 in reply to Tony
    Link to this post
    I found the solution.  The display order for the frontend can be set directly in the UI.  It doesn't require that you even go to the Administration >> Settings area.

  12. Greg
    Greg avatar
    16 posts
    Registered:
    11 May 2011
    10 Sep 2013 in reply to Tony
    Link to this post
    Where?
    In the widget properties, I go to "Advanced--Home--ControlDefinition--Views--DynamicContentMasterView" and set the sort expression to the name of my custom field and hit "Save" but when I go back in, it still says "PublicationDate Desc"  I've tried several field names, but It always reverts back to the default.
12 posts, 0 answered