COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: AnuElza on 24 Mar 2017 10:08:57 AM

Title: Exapand Collapse without using Javascript
Post by: AnuElza on 24 Mar 2017 10:08:57 AM
Hi,

I am trying to implement expand and collapse feature in a crosstab report. I have found that configuration parameter (VIEWER_JS_EXPAND_COLLAPSE_CONTROLS_DEFAULT) can be changed to achieve this.
However this works as long as I create the report by just drag and drop data items in the report. If I do any modifications to any of those data items, this doesn't work anymore.

Does any has any experience in achieving expand collapse hierarchy using this configuration or any other way to achieve this feature?

Any insight will be appreciated!
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 24 Mar 2017 10:15:49 AM
This is one of the frustrating things with extended data items. Is there a reason you're looking for a solution without JavaScript? Would JS that uses the Prompt API (and is therefor IBM supported) be okay?
Title: Re: Exapand Collapse without using Javascript
Post by: AnuElza on 24 Mar 2017 11:08:57 AM
Thanks for the response. I am not an expert in using JS or prompt API. But I would like to try JS that uses prompt API if you have any solution.

Also, a little bit more on the environment here; I am using Cognos 11.3 with TM1 as the source.

The reason for not using JS is because the Client is skeptical about it.

Thanks!
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 24 Mar 2017 12:49:06 PM
C11 does change things a bit. Are you using interactive mode? If you aren't, this solution should still work:
http://cognospaul.com/2014/09/29/expand-collapse-cognos/

If you are, it's on my list of solutions to migrate, but it won't be ready for at least another month.
Title: Re: Exapand Collapse without using Javascript
Post by: AnalyticsWithJay on 24 Mar 2017 02:26:52 PM
When all browsers support HTML5, you will be able to do this using the <details> tag. Until then you'll need to use Javascript.

When you can use the API it's always better to do so. However, don't shy away from leveraging other Javascript libraries as well. CA 11 has significantly changed the way JS is implemented (for better), and it already comes with the jQuery library without conflict.
Title: Re: Exapand Collapse without using Javascript
Post by: AnuElza on 24 Mar 2017 03:14:35 PM
Thanks CognosPaul. Let me give this in my model.
Title: Re: Exapand Collapse without using Javascript
Post by: aussieadam on 29 Mar 2017 08:54:56 AM
I wouldn't recommend doing it without javascript, but you're still looking for a way...
You could always put what you want to hide in a conditional block. Then add a drill-through to the same report which passes a value that the conditional block uses to determine show/hide. Big issue with this would be it has to generate the report again so i definitely wouldn't recommend this method.
Title: Re: Exapand Collapse without using Javascript
Post by: Blue on 12 Apr 2017 09:20:06 PM
Have you tried using a render variable?

Create a checkbox prompt with a single option (e.g. use: 1, display "Show") and default set to 0.
Create a variable that is true/yes when checkbox option = 1.
Apply the variable as the render var for the object to show/hide.  Deselect the box to hide, select to show.

Title: Re: Exapand Collapse without using Javascript
Post by: boolabonga on 22 Feb 2018 11:03:22 AM
Hi CognosPaul,

Regarding your reply to this topic on Mar 24, 2017,  have you made any progress migrating the JS expand/collapse functionality to CA 11 for Interactive mode?

Thanks!
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 22 Feb 2018 11:21:36 AM
Check it out: http://www.pmsquare.com/main/blog/custom-javascript-in-cognos-expand-and-collapse/

(https://i2.wp.com/www.pmsquare.com/main/wp-content/uploads/2017/09/6.-expandInAction-1.gif) (http://www.pmsquare.com/main/blog/custom-javascript-in-cognos-expand-and-collapse/)

Unless you're specifically asking about the one that uses the mun to expand and collapse. Haven't had a chance to adapt that one yet.
Title: Re: Exapand Collapse without using Javascript
Post by: Cognos123!!! on 19 Mar 2018 12:21:32 AM
Paul,
I checked the link you provided with the sample report.  Can you please provide the .js file as well?

Thanks!
Title: Re: Exapand Collapse without using Javascript
Post by: chepitoleon on 30 Jul 2018 05:09:56 PM
Quote from: CognosPaul on 22 Feb 2018 11:21:36 AM
Check it out: http://www.pmsquare.com/main/blog/custom-javascript-in-cognos-expand-and-collapse/

(https://i2.wp.com/www.pmsquare.com/main/wp-content/uploads/2017/09/6.-expandInAction-1.gif) (http://www.pmsquare.com/main/blog/custom-javascript-in-cognos-expand-and-collapse/)

Unless you're specifically asking about the one that uses the mun to expand and collapse. Haven't had a chance to adapt that one yet.

Hey

I am getting this error
Failed to Load Module
script error

anybody tried this solution?




Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 30 Jul 2018 06:22:23 PM
It works great for me. Are you storing the JS files in a place that's accessible to your browser? The module location should be a fully qualified path - relative paths tend to cause problems when switching from Report Studio to viewer.
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 30 Jul 2018 06:32:04 PM
Quote from: Cognos123!!! on 19 Mar 2018 12:21:32 AM
Paul,
I checked the link you provided with the sample report.  Can you please provide the .js file as well?

Thanks!
Just noticed this now. The link should now provide both the report XML and JS. Previously it would alternate between the report.txt and expandCollapse.js because of weirdness with the download widget being used.
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 07 Aug 2018 03:00:34 AM
Hey Paul,

Have you managed to create a expand and collapse that is compatible with interactive mode (custom control) ? because this only works in non-interactive mode ?
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 08 Aug 2018 10:15:28 AM
Hi Oscar,

This was actually designed for Interactive mode. Is it not working for you? What error are you getting?
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 09 Aug 2018 02:07:38 AM
Hey Paul,

I havent tried it yet but its embedded javascript right ? and thought that you should avoid that when using interactive mode. I'll try to use it because this could be a really good option/solution if the report can't generate lowest detailed levels at once due to performance issues as I have encountered before.
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 09 Aug 2018 03:48:53 AM
I just tried the script and get the error:
"Method not found: Draw"
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 09 Aug 2018 04:19:53 AM
I noticed now that the draw method was correlated to the UI-type and since the javascript doesnt contain a draw method it shouldnt use a UI-type.

But one weird thing with the javascript is that when I run the report and expand the levels the whole crosstab is slightly moving a little bit back and forth depending on if i expand or collapse which is somewhat annoying.

*****Solved it with "No wrap"*****
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 09 Aug 2018 09:10:29 AM
When I try to do it on time dimension:
descendants(
[CBI Sales].[Date].[Year - Month - Day].[Year],[CBI Sales].[Date].[Year - Month - Day].[Year Month Day],
self beforewithmember
)
it only displays +2006 in the crosstab but it should display:
+2006
+2007
+2008
+2009
etc

No matter on what dimension I do it on it only displays the first member in the level (2006 being the first member in the Year- Monh - Day level)
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 14 Aug 2018 10:11:52 AM
*Bump*
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 14 Aug 2018 11:43:10 AM
Is the padding set up to "based on the level of the hierarchy"? Indentation type based on relative works incorrectly.

If that's set up correctly, attach the report xml. I'll take a look.
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 15 Aug 2018 03:08:04 AM
Hey Paul,

I'll attach the XML here:
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 15 Aug 2018 08:53:04 AM
Two possibilities.

1. In the sample you gave you were filtering on a single year.
2. Make sure the crosstab isn't paginating. Easiest way is to select the crosstab, open pagination from the properties, and invert the checks. Check "Repeat every page" and uncheck both "allow" options.
Title: Re: Exapand Collapse without using Javascript
Post by: oscarca on 15 Aug 2018 09:18:15 AM
It works now!!

Thank you Paul, you are truly great as always.
Title: Re: Exapand Collapse without using Javascript
Post by: cognostechie on 16 Aug 2018 12:09:37 PM
The expand/collapse is an out-of-the-box feature in Report Studio so it should still be available in C11.

Click on 'Drill options' and there are different settings to choose from. I used this quiet a while ago so don't remember completely but one of those settings was 'preserve' which would keep the higher level visible on the report when you expand to see the lower level. 
Title: Re: Exapand Collapse without using Javascript
Post by: CognosPaul on 16 Aug 2018 05:38:05 PM
The drill options were neutered in C11 interactive mode unfortunately. I've raised the issue and hopefully we'll get the drill options back at some point.