Gets a sort level of this Column. If this column is not sorted, the property returns -1.

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public int SortLevel { get; }
Visual Basic
Public ReadOnly Property SortLevel As Integer
	Get
Visual C++
public:
property int SortLevel {
	int get ();
}
F#
member SortLevel : int with get

Property Value

Type: Int32
The sort level.

Remarks

.Net Grid sorting depends on headers. Sorted columns are stored in Header.SortedColumns. To enable sorting you have to use Column.SortDirection property. Calling this property for multiple columns sets multiple sorting by these columns. To cancel sorting, call Clear()()()()Header.SortedColumns.Clear().
 Copy imageCopy
public void SortedColumnsExample(Grid grid)
{
    //Add a new header on the top hierarchical level (level 0)
    Header header = new Header();
    header.Add(new Column("Column1"));
    header.Add(new Column("Column2"));
    header.Add(new Column("Column3"));
    grid.Headers.Add(header);

    Console.WriteLine("Sorted columns count: {0}", header.GroupedColumns.Count);

    header.SortedColumns.Clear();

    //Set multiple sort by two columns
    header["Column1"].SortDirection = SortDirection.Ascending;
    header["Column3"].SortDirection = SortDirection.Ascending;

    Console.WriteLine("Columns count: {0}", header.Count);
    Console.WriteLine("Sorted columns count: {0}", header.SortedColumns.Count);

    //Change the sort direction
    header["Column3"].SortDirection = SortDirection.Descending;

    //Iterate in all sorted columns
    foreach (Column column in header.SortedColumns)
    {
        Console.WriteLine("Sorted column: id = '{0}', index = {1}, visible index = {2}, sort level = {3}, sort direction = {4}", column.Id, column.Index, column.VisibleIndex, column.SortLevel, column.SortDirection);
    }

    //Remove sort
    header.SortedColumns.Clear();
    Console.WriteLine("Columns count: {0}", header.Count);
    Console.WriteLine("Sorted columns count: {0}", header.SortedColumns.Count);
}

//Console output:
Sorted columns count: 0
Columns count: 3
Sorted columns count: 2
Sorted column: id = 'Column1', index = 0, visible index = 0, sort level = 0, sort direction = Ascending
Sorted column: id = 'Column3', index = 2, visible index = 2, sort level = 1, sort direction = Descending
Columns count: 3
Sorted columns count: 0

See Also