Search This Blog

Friday, May 3, 2013

ListView CollectionSource improvements with regard to sorting



I think you will be pleased to know that in the upcoming 13.1 version we have made several refactorings of  the core parts of our framework that allowed us to implement a few features requested by our customers:

Core - Provide sorting capabilities to the CollectionSourceBase class
Core - Support ListView sorting settings from the application model in Server Mode
Core - Pass sorting options from the application model into PropertyCollectionSource

Now, when you add/remove the CollectionSourceBase.Sorting list items, sorting is immediately applied to the inner collection. Do not add several elements one after another. Instead, populate a temporary SortProperty list and then assign it to CollectionSourceBase.Sorting. The example below is taken from the ListView.LoadModelCore method implementation.
 
[C#]
List<SortProperty> sorting = new List<SortProperty>(); foreach(IModelSortProperty sortProperty in Model.Sorting) { sorting.Add(new SortProperty(sortProperty.PropertyName, sortProperty.Direction)); } collectionSource.Sorting = sorting;
In this instance, all SortProperty items will be applied simultaneously.

We have also added the CollectionSourceBase.CanApplySorting property. When it is set to true, sorting options specified in the application model are applied. In the CollectionSource descendant, the default value of this property is true. Take special note that in the PropertyCollectionSource descendant the default value is false. This is done to avoid accidental overriding of sorting specified in a collection property getter.

No comments:

Post a Comment