If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Prompts in a list container

Started by toddbutt, 05 Oct 2014 05:12:05 PM

Previous topic - Next topic

toddbutt

I have a list of values on my prompt page displayed in a list container.  There are 1 to X values being displayed..I will never know how many because of the cascading prompts before it.  Each value has a radio button with it with choices A, B, or C.  A being the default for each record.

I have a list container with the records displaying.  I have dropped a value prompt in the container and set it as a radio button group. I have added the static choices and everything displays.  So far so good.

I am also trying to display each radio button group horizontally.  I have used CognosPaul's javascript code and it works...sort of.  It works for only the first record.  I assume because the div id is hard coded and only the first record has that id name (something like that).  I have tried changing the javascript to programmatically change the id so that each div id has a unique name.  No luck.  My javascript knowledge is limited but I am trying to learn to fish instead of relying on someone to write it for me.  Any help on how to tackle this would be greatly appreciated.

Of course, the next logical step after getting this implemented is to capture which records have option A, which have option B, and which have option C.  I have to pass those to reports that need to run for each option on the other side.  I have no idea where to start on that one.  First things first though.

CognosPaul

Can you post the report XML?

Also, which version are you working with? The DOM structure changes and breaks my JS. Are you giving the prompt a width? It might be trying to wrap the elements. Try setting white-space nowrap on the prompt.

toddbutt

The version is 10.2.1  Below is the <contents> section of the report.  When the list displays on the screen, the first record displays the RadioGroup horizontally.  The other records display the RadioGroup vertically.

<contents>
   <HTMLItem description="Scripts">
      <dataSource>
         <staticValue>&lt;script type="text/javascript"&gt;
         function inlineRadios(child){
            if((child.type == "radio")||(child.type == "checkbox"))
            {
            child.parentNode.parentNode.style.display="inline";
            child.parentNode.parentNode.style.whiteSpace="noWrap";
            }
         }

         function promptDescendants (node)
         {
                 for (var i = 0; i &lt; node.childNodes.length; i++)
                 {
                   var child = node.childNodes;
                   inlineRadios(child);
                   promptDescendants(child);
                 }
         }

   
         &lt;/script&gt;
         </staticValue>
      </dataSource>
   </HTMLItem>

   <list horizontalPagination="true" name="List1" refQuery="Query4" rowsPerPage="500">
      <noDataHandler>
         <contents>
            <block>
               <contents>
                  <textItem>
                     <dataSource>
                        <staticValue>No Data Available</staticValue>
                     </dataSource>
                     <style>
                        <CSS value="padding:10px 18px;"/>
                     </style>
                  </textItem>
               </contents>
            </block>
         </contents>
      </noDataHandler>
      <style>
         <CSS value="border-collapse:collapse"/>
         <defaultStyles>
            <defaultStyle refStyle="ls"/>
         </defaultStyles>
      </style>
      <listColumns>
         <listColumn>
            <listColumnTitle>
               <style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemLabel refDataItem="Contract Number"/></dataSource></textItem></contents>
            </listColumnTitle>
            <listColumnBody>
               <style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemValue refDataItem="Contract Number"/></dataSource></textItem></contents>
            </listColumnBody>
         </listColumn>
         <listColumn>
            <listColumnTitle>
               <style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemLabel refDataItem="PopType"/></dataSource></textItem></contents>
            </listColumnTitle>
            <listColumnBody>
               <style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemValue refDataItem="PopType"/></dataSource></textItem></contents>
            </listColumnBody>
         </listColumn>
         <listColumn>
            <listColumnTitle>
               <style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemLabel refDataItem="MemberAttributes"/></dataSource></textItem></contents>
            </listColumnTitle>
            <listColumnBody>
               <style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemValue refDataItem="MemberAttributes"/></dataSource></textItem></contents>
            </listColumnBody>
         </listColumn>
         <listColumn>
            <listColumnTitle>
               <style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemLabel refDataItem="Row_Number"/></dataSource></textItem></contents>
            </listColumnTitle>
            <listColumnBody>
               <style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style>
               <contents><textItem><dataSource><dataItemValue refDataItem="Row_Number"/></dataSource></textItem></contents>
            </listColumnBody>
         </listColumn>
         <listColumn>
            <listColumnTitle>
               <style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style>
               <contents><textItem><dataSource><staticValue></staticValue></dataSource></textItem></contents>
            </listColumnTitle>
            <listColumnBody>
               <style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles><CSS value="white-space:nowrap"/></style>
               <contents>
                  <HTMLItem>
                     <dataSource>
                        <staticValue>&lt;div id="RadioPrompt1"&gt;</staticValue>
                     </dataSource>
                  </HTMLItem>
                  <selectValue parameter="Parameter1" selectValueUI="radioGroup">
                     <selectOptions>
                        <selectOption useValue="Current"><displayValue>Current</displayValue></selectOption>
                        <selectOption useValue="Blended"><displayValue>Blended</displayValue></selectOption>
                        <selectOption useValue="Remove"><displayValue>Remove</displayValue></selectOption>
                     </selectOptions>
                     <style><CSS value="width:210px"/></style>
                     <defaultSelections><defaultSimpleSelection>Current</defaultSimpleSelection></defaultSelections>
                  </selectValue>
                  <HTMLItem>
                     <dataSource>
                        <staticValue>&lt;/div&gt; &lt;script&gt;promptDescendants(document.getElementById('RadioPrompt1'));&lt;/script&gt;
                        </staticValue>
                     </dataSource>
                  </HTMLItem>
               </contents>
            </listColumnBody>
         </listColumn>
      </listColumns>
      <sortList>
         <sortItem refDataItem="Contract Number"/>
         <sortItem refDataItem="PopType" sortOrder="descending"/>
         <sortItem refDataItem="MemberAttributes"/>
      </sortList>
      <listOverallGroup>
         <listFooter>
            <listRows>
               <listRow>
                  <rowCells>
                     <rowCell colSpan="5">
                        <contents>
                           <block>
                              <contents>
                                 <textItem>
                                    <dataSource>
                                       <staticValue> </staticValue>
                                    </dataSource>
                                 </textItem>
                              </contents>
                           </block>
                        </contents>
                        <style>
                           <defaultStyles>
                              <defaultStyle refStyle="is"/>
                           </defaultStyles>
                        </style>
                     </rowCell>
                  </rowCells>
               </listRow>
            </listRows>
         </listFooter>
      </listOverallGroup>
   </list>
</contents>

CognosPaul

Okay, I get the problem now.

This will be difficult to achieve. The JS function getElementById() will return the first element with the matching id.

How do you need to use the values? As it stands now the prompts all have the same parameter name, so Cognos will use only one of them for the parameter.