Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort crystal report in the web

Status
Not open for further replies.

ehx6

IS-IT--Management
May 20, 2004
150
US
hi I have created a one crystal report in v10 advance developer. Then created an aspx page that once it is loaded, it calls the crystal report and show the report online. I want to be able to once I click on any report colum, to sort the data accordinly. This function is like creating datagrid and have column sort feature. Can I do that in crystal report v 10
Thanks
Ehx
 
Hi, Not that way..
The report is a static object once it is displayed. You can, however, pass a parameter to the report that identifies the sort field ( use a drop-down list to allow the user to pick one) and create a formula to determine which field was requested and sort on the formula instead on any field.

[profile]

 
You can also suggest that the users export the report to Excel to allow for that.

Click the envelope icon, select Excel, and they're good.

-k
 
If the desired final result is a nicely formatted printed report, consider this:
Web developers work up a page to allow selection of data based on criteria selected by users. Users may then sort data in grid by clicking on column headers. If users then desire report based on this criteria and sort order, the report is then called via the web app. (Yes, report data may vary slightly from what is shown on screen).

The sql in the report is in a 'command' and the entire where clause is passed as one parameter, to allow for the addition of the dynamic 'order by' clause.

command:
select * from tablex
where {@parameter}

parameter may contain many criteria, including the order by clause.

This is a method suggested by A.Harper in her book 'Crystal Reports 9 on Oracle'; very cool book. (this may depend on your datasource).

Do export to excel, if that is all that is needed.
 
Hi pelajhia and the rest of the guys. Thanks for all your inputs. I am more likely to have a drop down list to pass the sort order critiera. I am Using MS sql server and crv10 advance developer. The way I create the crystal report is I create a view in the database(which connect multiple tables) and the view as a datasource for the crystal report. so I think in the aspx page that load the crystal report, do I apply the input parameter inside the aspx and if so how. thanks for your input.
Ehx
 
You may select from the view as if it were a table via a command just as shown above.
In the database expert, when you have made your connection to the database, you should see a list of owners/tables, and ABOVE that, an option to add a command (if you are not familiar with getting to this point).
If you double click that, a pop up will display where you may enter the sql to select columns from the view. You may click the 'create' button on the right to create a parameter for use within this command (eg: {@WhereClause}).
Create the parameter as a string, then once created, double click it to get it into the sql on the left.

example sql:
select col1, col2 from owner.rpt_view where {@WhereClause}

The where clause will be a string build by the web app looking something like:
trans_id =12455
order by col1

final select statement sent to db:
select col1, col2 from owner.rpt_view where trans_id =12455 order by col1

 
Thanks for your help.
here what I came up and it is not working:
CrystalReportViewer1.SelectionFormula = " {v_sales_price_vs_cost.project_Name} ='" & g_fldname & " '"

----- above is working where I pass field name from a combo---
but when I want to add sort by field name, it is not working
CrystalReportViewer1.SelectionFormula = " {v_sales_price_vs_cost.project_Name} ='" & g_fldname & " '"
sort by {v_sales_price_vs_cost.employee}

I do appreciate your help

thanks
Ehx

 
If I am understanding your code, you are trying to build a crystal selection formula and include a sort by. This can not be done, as far as I know.
Unfortunately, you HAVE to put your sql into a 'SQL Command', as described above in order to use the method I am referring to. Sorry I did not name it correctly previously - if you need more help getting there, let me know.
THEN you can create a parameter which can include everything after the 'where' clause.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top