C1.C1Report Namespace > Group Class : Sort Property |
The specified sorting is applied to the content of the Group.GroupBy property. For example, if Group.GroupBy contains the expression "FirstName" and Group.Sort is set to "Ascending", then the group will be sorted in ascending order based on the content of the "FirstName" column in the data source.
Note that the sorting is performed by the data source itself, not by C1Report. Because of this, sorting is always based on column names rather than calculated expressions. If the Group.GroupBy property contains a calculated expression, the component will extract the first column name from the expression and will sort based on that value. For example, if Group.GroupBy is set to "Left(FirstName, 3)", the sorting will be based on the "FirstName" column, not on the first three characters of the first names.
This can present problems in a few cases, especially if you want to sort based on date parts (year, month, quarter). In these cases, the recommended procedure is to add a calculated column to the data source (by changing the SQL statement used to retrieve the data), then set the Group.GroupBy property to the name of the calculated column.
string sql = "SELECT *, DATEPART('q', HireDate) AS HireQuarter " + "FROM Employees"; c1r.DataSource.RecordSource = sql; c1r.Groups[0].GroupBy = "HireQuarter"; c1r.Groups[0].Sort = SortEnum.Ascending;
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2