|
Report Application Server .NET SDK Developer Guide
|
|
To modify a sort
|
|
- Find a field that the report is sorted on.
The DataDefinition.ResultFields property returns all fields that have been added to the report design.
|
Visual Basic
|
|
|
Dim resultFields As Fields = rcd.DataDefController.DataDefinition.ResultFields Dim sortField As Field = DirectCast(resultFields.FindField("{Customer.Last_Years_Sales}", CrFieldDisplayNameTypeEnum.crFieldDisplayNameFormula, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS), Field)
|
|
C#
|
|
|
Fields resultFields = rcd.DataDefController.DataDefinition.ResultFields; Field sortField = (Field)resultFields.FindField("{Customer.Last_Years_Sales}", CrFieldDisplayNameTypeEnum.crFieldDisplayNameFormula, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS);
|
- Retrieve the SortController object.
|
Visual Basic
|
|
|
Dim sortController As SortController = rcd.DataDefController.SortController
|
|
C#
|
|
|
SortController sortController = rcd.DataDefController.SortController;
|
- Retrieve the Sort object.
|
Visual Basic
|
|
|
Dim oldSort As ISCRSort = sortController.FindSort(sortField)
|
|
C#
|
|
|
ISCRSort oldSort = sortController.FindSort(sortField);
|
- Create a new Sort object, set the field to sort on with the SortField property, and set the direction of the sort.
|
Visual Basic
|
|
|
Dim newSort As ISCRSort = New Sort() newSort.SortField = sortField newSort.Direction = CrSortDirectionEnum.crSortDirectionDescendingOrder
|
|
C#
|
|
|
ISCRSort newSort = new Sort(); newSort.SortField = sortField; newSort.Direction = CrSortDirectionEnum.crSortDirectionDescendingOrder;
|
- Call the Modify method of the SortController class to add the new sort to the report based on the chosen field.
The first parameter of the Modify method specifies the original sorting definition to be modified. The second parameter specifies the new sorting definition.
|
Visual Basic
|
|
|
sortController.Modify(oldSort, newSort)
|
|
C#
|
|
|
sortController.Modify(oldSort, newSort);
|
The following code modifies a report that contains a sort based on the Customer.Last_Years_Sales field. It changes the sort direction to descending order.
|
Visual Basic
|
|
|
Private Sub ModifySortDirection(ByVal rcd As ISCDReportClientDocument) Dim resultFields As Fields = rcd.DataDefController.DataDefinition.ResultFields Dim sortField As Field = DirectCast(resultFields.FindField("{Customer.Last_Years_Sales}", CrFieldDisplayNameTypeEnum.crFieldDisplayNameFormula, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS), Field) Dim sortController As SortController = rcd.DataDefController.SortController Dim oldSort As ISCRSort = sortController.FindSort(sortField) Dim newSort As ISCRSort = New Sort() newSort.SortField = sortField newSort.Direction = CrSortDirectionEnum.crSortDirectionDescendingOrder sortController.Modify(oldSort, newSort) End Sub
|
|
C#
|
|
|
private void ModifySortDirection(ISCDReportClientDocument rcd) { Fields resultFields = rcd.DataDefController.DataDefinition.ResultFields; Field sortField = (Field)resultFields.FindField("{Customer.Last_Years_Sales}", CrFieldDisplayNameTypeEnum.crFieldDisplayNameFormula, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS); SortController sortController = rcd.DataDefController.SortController; ISCRSort oldSort = sortController.FindSort(sortField); ISCRSort newSort = new Sort(); newSort.SortField = sortField; newSort.Direction = CrSortDirectionEnum.crSortDirectionDescendingOrder; sortController.Modify(oldSort, newSort); }
|
This list includes the classes used by the sample code:
- CrystalDecisions.Enterprise
- CrystalDecisions.ReportAppServer.ClientDoc
- CrystalDecisions.ReportAppServer.Controllers
- CrystalDecisions.ReportAppServer.DataDefModel
© 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 Help generator