Articles in this section
Category / Section

How to avoid clipping of Sort numbers when sorting more than 9 columns?

2 mins read

GridDataControl allows sorting of table data against one or more columns. When Sorting is applied, the Grid rearranges the data to match with the current sort criteria, in ascending or descending order. The number of columns that can be sorted is unlimited. GridDataControl.ShowSortNumber property enables the visibility of the sorting order of the column at the top right corner of the column HeaderCell. However, when sorting more than 9 columns, the order of the column in the HeaderCell is clipped as shown in the following screenshot.

Figure 1: Clipped Sort number

This happens because sorting more than 9 columns is a rare case, hence, the grid by default, allocates width for displaying sort number of a single digit only. However GridDataControl provides a way to avoid this clipping of sort numbers by customizing the width allocated for the sort numbers in the HeaderCell. The property SortStringWidth” in the GridDataHeaderCellControl class allows you to set custom width for displaying the sort icon and sort numbers. The default value of this property is 25. Setting values greater than 25 increases the width for displaying the sort numbers in the header cell thereby avoiding the clipping of sort numbers, when sorting more than 9 columns.

Property

DataType

Description

SortStringWidth

double

This property is used to set the width for displaying the sort icon and sort numbers in the HeaderCell.

Default ValueThe default value of this property is 25, to display the sort icon and sort numbers of one digit.

The following code example demonstrates how to enable the visibility of sorting order and set SortStringWidth for displaying sort numbers of more than one digit.

C#

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.dataGrid.ShowSortNumber = true;
        GridDataHeaderCellControl.SortStringWidth = 32;
    }
}

The following screenshot illustrates the output of the above code. You can see that the sort numbers of two digits are displayed, without being clipped.

Figure 2: Sort numbers in two digits displayed

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied