Skip to main content
Tab

CardViewColumn.SortOrder Property

Gets or sets the column’s sort order.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(ColumnSortOrder.None)]
public virtual ColumnSortOrder SortOrder { get; set; }

Property Value

Type Default Description
ColumnSortOrder None

A ColumnSortOrder enumeration value that specifies the column’s sort order.

Available values:

Name Description
None

No sorting is applied to a column.

Ascending

Sorts the column in ascending order.

Descending

Sorts the columns in descending order.

Remarks

Read the SortOrder property’s value to determine which sort order is currently applied to the column. Assign a value to this property to sort data by the current column’s values.

You can also use the CardViewColumn.SortAscending and CardViewColumn.SortDescending methods to specify the desired sort order. To clear sorting, use the CardViewColumn.UnSort method.

Any previous sorting is not cleared when changing the SortOrder property’s value. The new sort order applies an additional sorting condition to the one previously applied. The newly sorted column is added to the collection of sorted columns. Its index within the collection can be obtained using the CardViewColumn.SortIndex property. The number of sorted columns is returned by the ASPxGridBase.SortCount property.

Sorting is allowed if the ASPxGridBehaviorSettings.AllowSort property is set to true.

Example

Web Forms approach:

Note

For a full example, see the CardView - Sorting (Web Forms) demo.

<dx:ASPxCardView ID="ASPxCardView1" runat="server" DataSourceID="HomesDataSource" 
    EnableCardsCache="false" Width="100%">
    <Columns>
        ...
        <dx:CardViewTextColumn FieldName="Price" SortOrder="Ascending">
            <PropertiesTextEdit DisplayFormatString="c" />
        </dx:CardViewTextColumn>
        <dx:CardViewImageColumn FieldName="PhotoUrl" Settings-AllowSort="False">
            <PropertiesImage ImageWidth="250" />
        </dx:CardViewImageColumn>
    </Columns>
    <CardLayoutProperties ColCount="2">
        <Items>
        ...
        </Items>
    </CardLayoutProperties>
</dx:ASPxCardView>

MVC approach:

Note

For a full example, see the CardView - Sorting (MVC) demo.

@Html.DevExpress().CardView( settings => {
    settings.Name = "CardView";
    ...
    settings.Columns.Add(c =>{
        c.FieldName = "Price";
        c.SortOrder = ColumnSortOrder.Ascending;
        c.PropertiesEdit.DisplayFormatString = "c";
    });
    settings.Columns.Add(c => {
        c.FieldName = "PhotoUrl";
        c.ColumnType = MVCxCardViewColumnType.Image;
        ((ImageEditProperties)c.PropertiesEdit).ImageWidth = 250;
    });

    ...
}).Bind(Model).GetHtml()

Online Demos

See Also