views:

84

answers:

2

hi there i have written a program in C# . i have a problem in crystal report . i wanna sort data in a report by clicking on a link in header . is it possible in crystal report?

please help thanks...

A: 

Kinda.

If you distribute your reports with BusinesObjects Enterprise (BOE), you could:

  • create a report with a parameter field ({?sortedField) that will be used to set the report's sorting
  • create a formula field ({@sortedField}) that uses {?sortedField} to choose which database field should be used for sorting
  • reference {@sortedField} in the Report | Report Sort Expert
  • create a OpenDocument Url link in the field-header that would set the parameter field to the desired value and re-run the report.

If you don't use BOE, you could roll your own Url scheme to do something similar.

Example:

Assumptions

  • A report was created using Xtreme.mdb.
  • The report is a two-column listing of Customer Name (Customer.Customer Name) and Region (Customer.Region)

Implementation

Create two parameter fields:

AscSortedField - String; default value: CustomerName DescSortedField - String; default value: Ignored

Create two formula fields:

AscSortedField

//AscSortedField
//If the parameter's value isn't found, a NULL is returned (a good thing)
SELECT {?AscSortedField}
CASE "CustomerName": {Customer.Customer Name}
CASE "Region": {Customer.Region}

DescSortedField

//DescSortedField
//If the parameter's value isn't found, a NULL is returned (a good thing)
SELECT {?DescSortedField}
CASE "CustomerName": {Customer.Customer Name}
CASE "Region": {Customer.Region}

Open the report's Record Sort Expert. Add {@AscSortedField}; ensure that its Sort Direction is set 'Ascending'. Add {@DescSortedField}; ensure that its Sort Direction is set to 'Descending'.

Usage

If you want to sort the report by Customer Name in ascending order, set the AscSortedField parameter's value to 'CustomerName' and set the DescSortedField parameter's value to a dummy value (e.g. 'Ignored').

If you want to sort the report by Region in descending order, set the AscSortedField parameter's value to 'Ignored' and set the DescSortedField parameter's value to 'Region'.

Craig
can you give me an example,I use visual studio 2008 crystal report
Maryam Khalesi
A: 

I dont know exactly how that can be done in Crystal, look at how it can be done in FastReport.Net.And then Just repeat the same procedure in crystal.Hope you will get the idea, The principal is Data Sorting, then try to get the hints from it.

HERBERTS