COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: praveenb77 on 19 Mar 2014 02:48:32 PM

Title: Dynamic Sorting on List Columns
Post by: praveenb77 on 19 Mar 2014 02:48:32 PM
Hi,

I have to implement the dynamic sort on the list columns in a report. I have ample of scripts available on net but, nothing is working perfect. I have attached the script which is written by ibm folks in which i can apply the sort on the report intitial load ( when i do page down, sort is not working ).

Do anyone have a working script for the dynamic sorting functionality ?

Thanks!
Title: Re: Dynamic Sorting on List Columns
Post by: navissar on 19 Mar 2014 03:38:20 PM
There are two types of dynamic sort solutions for lists in Cognos.
1. Dynamic sort scripts that use JS to do the entire sorting - these run through all the items in the list and sort them. for these to work, your list cannot paginate.
These will work quickly on small datasets,but will perform terribly with long lists. See example here: http://www.cognosonsteroids.com/2012/04/sort-list-report-dynamically-using.html
2. Scripts that identify the selected column, give it to a sort parameter and reprompt the report. You should be after this kind if your list is long.
See here http://www.ibm.com/developerworks/data/library/cognos/reporting/scripting_techniques/page515.html
Title: Re: Dynamic Sorting on List Columns
Post by: Ammus1234 on 20 Mar 2014 02:12:30 AM
I have done something similar based on Prompt API + hidden prompt+calculated query item in the past.

Requirement was when the user clicks on the heading of the column, the report should retrieve top 10 records based on that column. I did it by placing an html on each title of the column and setting the value of a hidden prompt onclick. Based on the prompt value, the query will change and fetch the top 10.  :)
It was working perfectly in that case, as I wanted the full list to be refreshed every time and fetch the top 10. Also it was a dimensional reporting.

Hope this will help.
Title: Re: Dynamic Sorting on List Columns
Post by: praveenb77 on 20 Mar 2014 01:07:23 PM
Nimrod,

For the first type you have provided, the sorting is working fine only for String values but not for Numeric values.

Can you please help.

Thanks!
Title: Re: Dynamic Sorting on List Columns
Post by: navissar on 20 Mar 2014 03:32:55 PM
It isn't my custom to support other people's scripts. The script is definitely not a script which "I provided".
If I may, I also feel that commenting on a 2013 thread on top of opening this one is a bit of a forum abuse.
Also, it is quite clear to me that since you're paginating your list as is clear in your first message, that is probably why your scripts fail.

Having said that, I'm guessing by a quick browse through the code the reason it doesn't properly sort numeric is because of formats (commas and periods and such). You can use regular expressions to remove these.