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 .
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.
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.
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.
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
What you're accomplishing definitely won't be possible in 10.1.1. Is this purely a presentational requirement?
Yes Paul it's purely presentational requirement.
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.
Hi
Any luck in this requirement.
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.
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