In This Topic
Sorting is another way to organize data in ascending or descending order. In FlexReport, sorting is achieved by using DataSource.SortDefinitions.
Lets say you want to view the list of employees with their names in ascending order. In this case the list should be sorted by First Name. The following steps illustrate how to Sort the names of the list of employees in alphabetical order. This example uses sample created in FlexReport Quick Start.
- Add a C1Button to the form in the FlexReport Quick Start project.
- Set the C1Button Name to 'sortC1Button' and Text to 'Sort Report by Employee First Name'.
- Create Click event as sortC1Button_Click.
- Add the following code.
- Preview the report. Click Employees button to render the report.
- Click 'Sort Report by Employee First Name' button to view sorting in the report.
Sorting Data using FlexReportDesigner
The data in a report can be easily sorted using FlexReportDesigner. The steps to sort data in a report are as follows:
- Create a new report - Products Report - bound to Main data source through C1NWind.mdb. Select Product Name, Quantity Per Unit, and Stock as the text and calculated fields, so that the report appears as shown:
- To view the report where data is sorted by Product Name, go to Design mode.
- Click Data tab.
- Expand Data Sources node.
- Expand the Main data source to which the report is bound.
- Right-click Sort Definitions.
-
Select Add Sort Definition. Sort Definition dialog box appears.
-
Select ProductName, check the Ascending checkbox, and click OK.
-
Preview the report.