Search This Blog

Sunday, 14 September 2014

Sorting on column click



We see many Web applications where web page has been designed to give a rich sorting feature to end user. There uses click on any column and entire data gets sorted according to that column. Let’s design a report we can give this rich sorting feature to our end user.
Here I am assuming that you are done with your report design and you have to just introduce sort feature on various columns in your report.

Step 1. Right click on that particular column and 
select Text box Properties option. Refer Image-1
Image-1











 
Step 2. Now select Interactive Sorting option and also check the Enable sorting option on this textbox. Refer Image-2
 
Image-2
  
Step 3. You see other options available there and those are as
·        Choose what to sort:
(I) Detail Rows: if your report has only one group/row i.e. detail group/row then choose this option
(II) Groups: if your report has multiple groups and you want to sort the result specific to a group then choose this option
·        Sort by: select the available field name on which you want to perform an sort operation
·        Apply this sorting to all groups and data regions in: choose this option, if you want to sort the whole records specific to your dataset/table/table group

Step 4. You need to repeat the above steps on each column one by one on which you want to give sort feature. Once you done with this and preview your report, the columns will have icons as up-down arrows. Refer Image-3

Image-3



On Demand Sorting



Let’s give an option to our end user to sort the report output as per their choice. Not by report design.
To keep the sorting feature more rich and relevant, let’s go through with the following steps:
Step 1. Create a new parameter and list out all the field names under Available Values property of the parameter. Specify field names under Label as you want to show to your end user and keep the value same as in your dataset field name. Refer Image-1
Image-1















Step 2. Now open property window of your table’s group and select Sorting. Refer Image-2


Image-2






Step 3. Now put following expression under Sort by. Refer Image-3
=Fields(Parameters!p_sortby.Value).Value
Image-3