COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: basha971 on 01 Aug 2013 03:25:10 AM

Title: Disable Chek boxes in Multiselect Tree Prompt
Post by: basha971 on 01 Aug 2013 03:25:10 AM
Hi,
We have a requirement to disable check box in multi select treeprompt  for least level in hierarchy by using Java Script. Can any one please help me out on this .

Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: CognosPaul on 01 Aug 2013 04:56:09 AM
You can easily hide the last level of a tree prompt by putting a filter in the prompt's query:

roleValue('_levelNumber',currentMember([Cube].[Dim].[Hier])) > 4

Alternatively you can use this (http://www.ibm.com/developerworks/data/library/cognos/reporting/scripting_techniques/page548.html) JavaScript method from IBM to prevent users from selecting any level they shouldn't.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: basha971 on 01 Aug 2013 08:44:46 AM
Hi Paul,
Thanks for your response.
But here my requirement is different.
once user select any level  in tree prompt then all levels underneath that Corresponding level should be checked and disabled .Can we do this by using JavaScript.

Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: CognosPaul on 01 Aug 2013 09:44:44 AM
That will be difficult to accomplish as the checkboxes don't actually exist on the page until after the member has been expanded. There is some sort of weird listener on the tree prompt that prevents me from attaching my own listener.

There may be an mdx solution though. Can you give an example of what you're trying to accomplish? From what I'm getting,  if the user clicks on 2011 and Q1 2012 then all of the descendants should be returned to the set. If that's it, then you can use the descendants function with the self and beforewithmember flags.

Which version of Cognos are you using? Now that I'm thinking about it the 10.2 prompt api might provide a solution.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: basha971 on 01 Aug 2013 11:18:24 AM
Hi Paul,
We are using Cognos 10.1.1 version. Let me explain the requirement indetail. We will always pass the least level into report  from hierarchy. But while displaying  in treeprompt if you select  any level  underneath that  level should be checked and disabled .

Please see the below example  which consits of Region and Region Manager . If user selects 'A' region check box in tree prompt  it should  checked  and disabled  'P','Q' and 'S' region manager check boxes.



Region   Region Number
A   P
   Q
   R
B   S
   T
   V
C   W
   X
   Y
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: CognosPaul on 01 Aug 2013 12:27:38 PM
What you're accomplishing definitely won't be possible in 10.1.1. Is this purely a presentational requirement?
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: basha971 on 01 Aug 2013 12:31:46 PM
Yes Paul it's purely presentational requirement.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: CognosPaul on 01 Aug 2013 01:33:28 PM
Maybe you can create an event which monitors for DOM changes in the tree, then loop through and check the checkboxes. Mutation events are a little beyond my abilities at the moment, and I suspect that IE has little to no support for them.

Another idea - try wrapping the tree in a div, and check for mouse down events. If Cognos doesn't cancel the bubbling, you should be able to run a function each time the user clicks anywhere in that div. But the problem with that is you'll need to set it in a loop, because expanding isn't instant.

Very interesting requirement, I'll need to think on it.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: basha971 on 12 Aug 2013 02:18:42 AM
Hi
Any luck in this requirement.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: CognosPaul on 12 Aug 2013 12:33:07 PM
I don't think it's possible. There's simply no way to add a listener to detect when new members have been added to the tree.
Title: Re: Disable Chek boxes in Multiselect Tree Prompt
Post by: asif on 24 Oct 2014 09:23:20 AM
Hi,

Is there are way to disable the or grey out the parent checkbox in a tree-prompt if the child element(s) are selected?

Thanks