Module Builder: sorting list items?

Posted by Community Admin on 03-Aug-2018 01:41

Module Builder: sorting list items?

All Replies

Posted by Community Admin on 11-Jan-2012 00:00

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

Posted by Community Admin on 11-Jan-2012 00:00

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 ..

Posted by Community Admin on 11-Jan-2012 00:00

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

Posted by Community Admin on 11-Jan-2012 00:00

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

Posted by Community Admin on 13-Jan-2012 00:00

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

Posted by Community Admin on 13-Jan-2012 00:00

Hi Dimitar,

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

Steve

Posted by Community Admin on 13-Jan-2012 00:00

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

Posted by Community Admin on 13-Jan-2012 00:00

Oops.  No, I missed the "Telerik.Sitefinity.Model" namespace--working fine now.

Thanks,

Steve

Posted by Community Admin on 20-Jun-2012 00:00

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?

Posted by Community Admin on 24-Apr-2013 00:00

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?

Posted by Community Admin on 24-Apr-2013 00:00

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.

Posted by Community Admin on 10-Sep-2013 00:00

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.

This thread is closed