Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Dynamic Mutli Sorting in CR2008 Post Reply Post New Topic
Author Message
Ammu Thomas
Newbie
Newbie


Joined: 02 Feb 2009
Location: India
Online Status: Offline
Posts: 6
Quote Ammu Thomas Replybullet Topic: Dynamic Mutli Sorting in CR2008
    Posted: 24 Mar 2011 at 5:42pm
Hi
I am using Crystal report 2008 sp3 full build with hotfix 3.3 along with ASP.NET 2.0
I have implimented the multi field sorting using the record sort export and setting the sort order in the report designer.

Now my requirement is such that i would like to have dynamic sorting on multiple fileds while report is displayed in the UI.
Means suppose i have a report with Customer region,name,city,rating,status etc.

Now by using the sort control i would like to have the functionality in such a way that if user

a) first sorts on the region then the records should be first sorted by region
b) then sorts on the city then the records should be sorted first by region then by city
c) now sorts on the rating then the records should be sorted first by region ,second by city and then by rating

Now other user may do
a) first sorts on the rating then the records should be first sorted by rating
b) then sorts on the status then the records should be sorted first by rating then by status
c) now user sorts on the region then the records should be sorted first by rating,second by status and then by region

and so on the sorting criteria changes from user to user through the UI.

Is there any way to achieve the dynamic kind of sorting with Crytsal report 2008 where we can set the order of the fileds at sorting in UI dynamically .The sorting order of the fields are not known at the time of design of the report and its completely depends on the user's need.

Please let me know if you require any information on the same.

Thanks & Regards,
Ammu

Ammu
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Mar 2011 at 3:36am
while I have never used sort control, if the number of fields to sort by are finite and known you should be able to create a formula that will return a value that will allow you to sort dynamically.  This would be accomplished by grouping on the results of a formula.  For example: say your user enters region, city, ratings as the desired sort order, you could have a formula like:
 
local stringvar array str := split({?parameter}, ",");
local numbervar icount;
local stringvar sorted :="";
 
for icount = 1 to ubound(str) do(
  if str[icount] = "region" then sorted := sorted + {table.regionField} + "|";
  if str[icount] = "city" then sorted := sorted +{table.cityField} + "|";
  if str[icount] = "rating" then sorted := sorted +totext({table.ratingField}) + "|";
);
 
sorted
 
 
I may be off on the syntax for the 'for' loop, check help.  But that is the idea, bring a string, that should be unique as the result of a formula, then set the grouping to use the formula, and your report will be sorted.
 
HTH
 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.047 seconds.