New sorting definitions are added to a report with the CrystalDecisions.ReportAppServer.Controllers.SortController class. A sorting definition is defined by a field and a direction, however, not all fields can be grouped on. The CanSortOn method of the SortController class checks whether the field can be sorted on.
The order in which the sorting definitions appear in the Sorts collection is important as it represents the order by which sorting definitions are applied to records. When a sorting definition is removed, the indexes are re-organized so that the collection is still indexed from zero.
|
Visual Basic |
|
|
Dim dataDefController As DataDefController = rcd.DataDefController |
|
|
C# |
|
|
DataDefController dataDefController = rcd.DataDefController; |
|
The DataDefinition.ResultFields property returns all fields that have been added to the report design. This example assumes that the report design contains a Last_Years_Sales field called from a table called Customer.
|
Visual Basic |
|
|
Dim resultFields As Fields = dataDefController.DataDefinition.ResultFields |
|
|
C# |
|
|
Fields resultFields = dataDefController.DataDefinition.ResultFields; |
|
|
Visual Basic |
|
|
Dim sortController As SortController = dataDefController.SortController |
|
|
C# |
|
|
SortController sortController = dataDefController.SortController; |
|
|
Visual Basic |
|
|
Dim newSort As Sort = New SortClass() |
|
|
C# |
|
|
Sort newSort = new SortClass(); |
|
The first parameter of the Add method specifies the location of the new sorting definition in the Sorts collection. A value of -1 indicates that the new sorting definition will be added to the end of the Sorts collection. This means that the new sorting definition will be applied to records last after all other sorting definitions have been applied.
|
Visual Basic |
|
|
sortController.Add(0, newSort) |
|
|
C# |
|
|
sortController.Add(0, newSort); |
|
The following code adds a new sorting definition to a report based on the field Customer.Last_Years_Sales. This example checks whether the selected field is a valid field to sort on before attempting to add the sorting definition.
|
Visual Basic |
|
|
Private Sub AddSort(ByVal rcd As ISCDReportClientDocument) |
|
|
C# |
|
|
private void AddSort(ISCDReportClientDocument rcd) |
|
This list includes the namespaces used by the sample code:
© 2021 SAP AG. All rights reserved.
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Created with the Personal Edition of HelpNDoc: Full-featured EBook editor