Skip to content

Commit

Permalink
NavigationItem.DataSourceListView - sort items alphabetically #467
Browse files Browse the repository at this point in the history
  • Loading branch information
apobekiaris committed Aug 4, 2019
1 parent 74bcc8b commit 642226a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Support/Build/go.ps1
Expand Up @@ -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
)

Expand Down
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -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<object>()
.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();
}
}
Expand Down

0 comments on commit 642226a

Please sign in to comment.