Back to Devexpress

XPBaseCollection.Sorting Property

xpo-devexpress-dot-xpo-dot-xpbasecollection-4e044f5f.md

latest4.7 KB
Original Source

XPBaseCollection.Sorting Property

Gets or sets the sort settings for the current collection.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public SortingCollection Sorting { get; set; }
vb
Public Property Sorting As SortingCollection

Property Value

TypeDescription
SortingCollection

The SortingCollection that specifies the sort order for the collection.

|

Remarks

Calling the SortingCollection‘s Add , Remove and Clear methods is not allowed. To sort a collection, a new SortingCollection object must be created and assigned to the Sorting property.

csharp
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
// ...
xpCollectionPerson.Sorting = new SortingCollection(
    new SortProperty("Name", SortingDirection.Ascending)
);
vb
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB
' ...
xpCollectionPerson.Sorting = New SortingCollection( _
    New SortProperty("Name", SortingDirection.Ascending) _
)

To learn more, see Sorting.

Note

For performance reasons, we recommend that you not use the JoinOperand in sort properties, as this significantly increases the number of queries sent to the server.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Sorting property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

xaf-how-to-display-a-collection-property-as-a-checked-list-box/CS/DXExample.Module.Win/WinCheckedListBoxPropertyEditor.cs#L28

csharp
if (checkedItems.Sorting.Count > 0) {
    dataSource.Sorting = checkedItems.Sorting;
} else if (!String.IsNullOrEmpty(classInfo.DefaultProperty)) {

asp-net-mvc-grid-custom-binding-and-xpo/CS/XPCustomBindingExample/XPO/XpoBindingHandlers.cs#L32

csharp
data.Criteria = CriteriaOperator.Parse(e.FilterExpression) & GetGroupFilter(e.GroupInfoList);
data.Sorting = GetSorting(e.State.SortedColumns, e.StartDataRowIndex != 0 || e.DataRowCount != 0);
data.SkipReturnedObjects = e.StartDataRowIndex;

xaf-how-to-display-a-collection-property-as-a-checked-list-box/VB/DXExample.Module.Win/WinCheckedListBoxPropertyEditor.vb#L32

vb
If checkedItems.Sorting.Count > 0 Then
    dataSource.Sorting = checkedItems.Sorting
ElseIf (Not String.IsNullOrEmpty(classInfo.DefaultProperty)) Then

asp-net-mvc-grid-custom-binding-and-xpo/VB/XPCustomBindingExample/XPO/XpoBindingHandlers.vb#L32

vb
data.Criteria = CriteriaOperator.Parse(e.FilterExpression) And GetGroupFilter(e.GroupInfoList)
data.Sorting = GetSorting(e.State.SortedColumns, e.StartDataRowIndex <> 0 OrElse e.DataRowCount <> 0)
data.SkipReturnedObjects = e.StartDataRowIndex

See Also

SortProperty

XPBaseCollection Class

XPBaseCollection Members

DevExpress.Xpo Namespace