Sort Function

Vote:
 
Hi, In EPiServer Edit mode you can choose different sorting alternatives on the page tree in the left side menu. I want to use the same sorting algorithm used on the page tree on my web page. I want this to be done automatically if I later want to change the sorting alternative. At the moment my web page only wants to sort the files according to date and time. How can I access the variable that gives me info regarding the file three's sorting algorithm? I'm using a databind that I'm trying to override.
#12854
Nov 30, 2006 14:39
Vote:
 
Hi. Since your list on the web page sort the pages by date and time, I presume you are using the EPiServer control NewsList. This control sort all the pages by date and time by default. Check out the property SortOrder on the NewsList (or the PageList) control in the SDK. This property is of the type FilterSortOrder, which is an Enum that contains these predefined sort orders: None CreatedDescending CreatedAscending Alphabetical Index ChangedDescending Rank PublishedAscending PublishedDescending If you want to make a custom sorting, say if you want to sort on two different properties, check out the property SortBy. Hope this helps. Frank :)
#15000
Nov 30, 2006 19:24
Vote:
 
Kjetil, I had trouble finding which property to use, because there isn't a "Sort Order" property - in fact it's called "PageChildOrderRule" -you can check the value of this by checking CurrentPage.Property["PageChildOrder"]. Also, if you need it, the property that corresponds to "Sort Index" in edit mode is named "PagePeerOrder". /Mark
#15001
Dec 01, 2006 10:44
Vote:
 
Oops - forgot to mention that the value returned by CurrentPage.Property["PageChildOrder"] will give you an int that corresponds to the EPiServe.Filters.FilterSortOrder that Frank mentioned.
#15002
Dec 01, 2006 10:49
Vote:
 
Thanks a lot guys! I will try this out over the weekend :) -Kjetil
#15003
Dec 01, 2006 14:52
Vote:
 
/// /// Returns the sort order of the parent page that should be used for childpages /// /// /// FilterSortOrder public static FilterSortOrder GetSortOrder(PageData pd) {return (FilterSortOrder)pd["PageChildOrderRule"];} used in:
#15004
Dec 04, 2006 13:54
Vote:
 
Hi again! I tried the tips but i'm still not getting the result i want. I'm sending in the code incase there are any clues for why this is not worknig for me. It seems like the last command (base.OnDataBinding(e)) does not work, or is ignored, and the listing is done based on the default. Thanks again for your help earlier and i'm feeling because of this i'm heading in the right direction :) public partial class Activities : EPiServer.UserControlBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) ActivityList.DataBind(); } protected override void OnDataBinding(EventArgs e) { EPiServer.WebControls.PageListData pageListDataControl = ActivityList; int searchForPageTypeID = (int)CurrentPage.Property["ActivityPageType"].Value; PageReference searchBelowPage = (PageReference)CurrentPage.Property["ActivitylistContainer"].Value; //This code only pics the pages relevant for listing... PageDataCollection filteredPages = Extra.code.EPiServerHelper.FindPages(searchForPageTypeID, ref searchBelowPage, ref pageListDataControl); if (filteredPages.Count == 0) { } pageListDataControl.DataSource = filteredPages; pageListDataControl.SortOrder = (EPiServer.Filters.FilterSortOrder)GetPage(searchBelowPage).Property["PageChildOrderRule"].Value; base.OnDataBinding(e); } }
#15005
Dec 04, 2006 14:32
Vote:
 
Kjetil - I had a bit of finger trouble before - the property name should be 'PageChildOrder', NOT 'PageChildOrderRule'
#15006
Dec 04, 2006 15:38
Vote:
 
Hi Mark, Thanks again for helping me :) I'm trying to use your code but having problems understanding in which file the first bit of code should be put? -Kjetil
#15007
Dec 06, 2006 15:37
Vote:
 

I tried the following variation to the Sort order

 

pageListDataControl.SortOrder = (EPiServer.Filters.FilterSortOrder)Enum.Parse(typeof(EPiServer.Filters.FilterSortOrder), CurrentPage["PageChildOrderRule"].ToString());

#28235
Feb 26, 2009 14:23
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.