Back to Devexpress

CardViewColumn.SortOrder Property

aspnet-devexpress-dot-web-dot-cardviewcolumn-3790b1de.md

latest4.7 KB
Original Source

CardViewColumn.SortOrder Property

Gets or sets the column’s sort order.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(ColumnSortOrder.None)]
public virtual ColumnSortOrder SortOrder { get; set; }
vb
<DefaultValue(ColumnSortOrder.None)>
Public Overridable Property SortOrder As ColumnSortOrder

Property Value

TypeDefaultDescription
ColumnSortOrderNone

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

|

Available values:

NameDescription
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.

aspx
<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.

cshtml
@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

AllowSort

SortIndex

SortAscending()

SortDescending()

UnSort()

Card View

CardViewColumn Class

CardViewColumn Members

DevExpress.Web Namespace