Sorting Data
You can sort data in reports the following two ways:
• Sort the data source object itself (for example, using a SQL statement with an ORDER BY clause).
• Add groups to the report and specify how each group should be sorted using the group's GroupBy and Sort properties.
Group sorting is done using the DataView.Sort property, which takes a list of column names only (not expressions on column names). So if your grouping expression is DatePart("yyyy", dateColumn), the control will actually sort on the dates in the dateColumn field, not on the years of those dates as most would expect.
To sort based on the dates, add a calculated column to the data table (by changing the SQL statement), and then group/sort on the calculated column instead. See the Sort property for an XML discussion of this, including a sample.
This is what the Sorting and Grouping editor looks like in the C1ReportDesigner application. Note the fields where you can specify group sorting:
If you use both approaches, the sorting set in the report groups will prevail (it is applied after the data has been retrieved from the database).
Sample Report Available
For the complete report, see report "19: Sorting" in the CommonTasks.xml report definition file, which is available for download from the CommonTasks sample on the ComponentOne HelpCentral Sample page.
|