Skip to main content
A newer version of this page is available. .
Tab

CardViewColumn.SortIndex Property

Gets or sets the column’s position among sorted columns.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

[DefaultValue(-1)]
public int SortIndex { get; set; }

Property Value

Type Default Description
Int32 -1

An integer value that specifies the zero-based column’s index among sorted columns. -1 if data is not sorted by this column.

Remarks

The ASPxCardView allows data sorting by multiple columns. Once a column is sorted, it is automatically added to the collection of sorted columns. If no columns were previously sorted, the column becomes the only element in the collection and gets the 0 sort index. If sorting by one more columns, the newly sorted column is appended to the collection and gets the 1 index, etc.

When data is sorted by multiple columns, you can change the position (order) of sorted columns using the SortIndex property. Note that changing the sorted columns position changes order of cards.

Setting the SortIndex property to a non-negative integer, the column is added to the sorted columns list. The column’s CardViewColumn.SortOrder property is automatically set to ColumnSortOrder.Ascending. Setting a column’s SortIndex property value to -1 cancels data sorting by this column.

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

Example

To focus a newly inserted card, it is necessary to know the keyValue of this card. You can get the value by handling the ASPxCardView.CardInserted event, which is raised after a new card has been added to the ASPxCardView data source.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Xpo.Metadata;

/// <summary>
/// Summary description for XpoHelper
/// </summary>
public static class XpoHelper {
    static XpoHelper () {
        CreateDefaultObjects();
    }

    public static Session GetNewSession () {
        return new Session(DataLayer);
    }

    public static UnitOfWork GetNewUnitOfWork () {
        return new UnitOfWork(DataLayer);
    }

    private readonly static object lockObject = new object();

    static IDataLayer fDataLayer;
    static IDataLayer DataLayer {
        get {
            if (fDataLayer == null) {
                lock (lockObject) {
                    fDataLayer = GetDataLayer();
                }
            }
            return fDataLayer;
        }
    }

    private static IDataLayer GetDataLayer () {
        XpoDefault.Session = null;

        InMemoryDataStore ds = new InMemoryDataStore();
        XPDictionary dict = new ReflectionDictionary();
        dict.GetDataStoreSchema(typeof(Customer).Assembly);

        return new ThreadSafeDataLayer(dict, ds);
    }

    static void CreateDefaultObjects () {
        using (UnitOfWork uow = GetNewUnitOfWork()) {
            Customer cust = new Customer(uow);
            cust.CompanyName = "Alfreds Futterkiste";
            cust.ContactName = "Maria Anders";
            cust.Country = "Germany";

            cust = new Customer(uow);
            cust.CompanyName = "Ana Trujillo Emparedados y helados";
            cust.ContactName = "Ana Trujillo";
            cust.Country = "Mexico";

            cust = new Customer(uow);
            cust.CompanyName = "Antonio Moreno Taquería";
            cust.ContactName = "Antonio Moreno";
            cust.Country = "Mexico";

            cust = new Customer(uow);
            cust.CompanyName = "Blondel père et fils";
            cust.ContactName = "Frédérique Citeaux";
            cust.Country = "France";

            cust = new Customer(uow);
            cust.CompanyName = "Berglunds snabbköp";
            cust.ContactName = "Christina Berglund";
            cust.Country = "Sweden";

            cust = new Customer(uow);
            cust.CompanyName = "Bottom-Dollar Markets";
            cust.ContactName = "Elizabeth Lincoln";
            cust.Country = "Canada";

            uow.CommitChanges();
        }
    }
}
See Also