From 642226a6f4b5ec832dc8f5822e81c3fa7f376124 Mon Sep 17 00:00:00 2001 From: Apostolis Bekiaris Date: Mon, 5 Aug 2019 02:38:06 +0300 Subject: [PATCH] NavigationItem.DataSourceListView - sort items alphabetically #467 --- Support/Build/go.ps1 | 2 +- .../Controllers/NavigationItemsController.cs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Support/Build/go.ps1 b/Support/Build/go.ps1 index aef643940d..0192dc1f10 100644 --- a/Support/Build/go.ps1 +++ b/Support/Build/go.ps1 @@ -7,7 +7,7 @@ param( [string[]]$taskList = @("Release"), [string]$nugetApiKey = $null, [string]$Repository = "eXpand", - [string]$XpandPwshVersion = "0.13.2", + [string]$XpandPwshVersion = "0.13.3", [bool]$ResolveNugetDependecies ) diff --git a/Xpand/Xpand.Persistent/Xpand.Persistent.Base/General/Controllers/NavigationItemsController.cs b/Xpand/Xpand.Persistent/Xpand.Persistent.Base/General/Controllers/NavigationItemsController.cs index bee3d707d1..00aa2c3e07 100644 --- a/Xpand/Xpand.Persistent/Xpand.Persistent.Base/General/Controllers/NavigationItemsController.cs +++ b/Xpand/Xpand.Persistent/Xpand.Persistent.Base/General/Controllers/NavigationItemsController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -91,13 +92,15 @@ public class NavigationItemsController:WindowController,IModelExtender{ var typeInfo = datasourceListView.ModelClass.TypeInfo; using (var collectionSourceBase = Application.CreateCollectionSource(objectSpace, typeInfo.Type, datasourceListView.Id)){ var listView = Application.CreateListView(datasourceListView, collectionSourceBase, true); - var proxyCollection = (ProxyCollection) collectionSourceBase.Collection; - for (var index = 0; index < proxyCollection.Count; index++) { - var obj = proxyCollection[index]; - var caption = datasourceListView.Columns.First(column => column.Index > -1).ModelMember.MemberInfo.GetValue(obj) + ""; - var id = datasourceListView.ModelClass.TypeInfo.KeyMember.GetValue(obj) + ""; - CreateChildNavigationItem(navigationItem, index, caption, id); + var infos = ((IEnumerable) collectionSourceBase.Collection).Cast() + .Select(_ => (id: $"{datasourceListView.ModelClass.TypeInfo.KeyMember.GetValue(_)}", + caption:$"{datasourceListView.Columns.First(column => column.Index > -1).ModelMember.MemberInfo.GetValue(_)}")) + .OrderBy(_ => _.caption).ToArray(); + for (var index = 0; index < infos.Length; index++) { + var info = infos[index]; + CreateChildNavigationItem(navigationItem, index, info.caption, info.id); } + listView.Dispose(); } }