开发者

Problem getting value from "Checkbox group value prompt"

I've value prompt with ui:checkbox group

parameter: p_IsLastMonth

Name: Prompt_IsLastMonth

ItemCount: 1; UseValue:Yes, DisplayValue: LastMonth?

and two Date Prompts.

Whenever the checkbox is checked, the UseValue 'Yes' is passed to the parameter 'p_IsLastMonth'. But whenever the checkbox is left as it is, it results in an error.

Element 'selectOptions' is not valid for content model: 'All(style,defaultSelections,conditionalStyles,conditionalRender,XMLAttributes)' 

I also tried giving a default value. But the default value has to be in the collection. But i want only one checkbox to be displayed.

I tried with html checkbox. But i'm not able to send the value 'either yes or no' to the parameter through javascript because however the finish button overrides the val开发者_如何学Pythonue.

Any help?


There are 2 ways you can use Parameters:

  1. Evaluate Parameter value
  2. Evaluate expression against Parameter value.

Either way your Parameter has some value, and no value is a kind of value. And you need to cater for empty value in some way. Eg:

 If (?Parameter? <>'') then ([Selection Criteria] = 'True') Else (1=1) 

OR

 ([Selection Criteria] = ?Parameter?) OR ?Parameter? = ''

There other ways of using parameters too. You should choose one that better suits situation and coding practices you are following.

You can use optional checkbox or text item. In Cognos 10 I get "Deselect" option under checkbox group.


Unfortunately, I don't think you can accomplish what you want to do with only one checkbox. The only way you can leave a value prompt unselected and still submit the prompt page is to make it "optional", which means no value will be passed. An option is to use two check boxes and make them "required" so that either "yes" or "no" must be selected (but this can result in both being selected, which isn't good), or preferably use a radio list with two values and "yes" as the default. There may be a javascript answer to this, but I try to avoid that as much as possible since it sometimes leaves you open to version upgrade issues. Using a radio list is your easiest option.


Well here is something that will work. I've done advanced scorecarding and dashboarding for years with Cognos and Javascript will work:

  1. Create a real cognos parameter that has both choices you need Yes/No with no being the default. Put them perhaps in a html table somewhere off the main real-estate of the report/param canvas. Once you have the param configed you can make the size as small as you want and then make the table/checkbox invisible by turning the visible property to no. Basically the users won't see these params. Don't do box-type = non or the parameter won't even get generated. You could also wait on hidding them until we get step 3 working(Make it easier to troubleshoot).

  2. Then create a HTML parameter that the user will use to interact with in the style that you want the users to see, and use javascript onchange events to manipulate the real hidden parameter by finding it via DOM model. You can make finding it easier by perhaps surrounding the hidden params with an HTML tag that has a unique name/ID and referencing the child items from there.

  3. Since your cognos parameter is invisible you may not even need to use a check box... you could simply use a hidden text box that has stores Yes/No. This will make your coding simplified on the javascript until you get used to it.

  4. Also When programming with javascript on Cognos i find using alert to echo a object's innerhtml to screen while troubleshooting to be very handy.

* One other less impressive approach if i remember right as well.. 1. Leave your original cognos style checkbox alone and create another cognos prompt that is always defaulted to "-NO-" and hidden on the canvas. 2. In the expressions used to evaluate the parameters the would evaulate the concatenation values of both params and you could take logical action based on those values. So if the concatted results were "-No-" then you know the original paramater was not selected and to use "No". etc... I believe there could be a nuance to getting this to evaluate correctly in the expression editors but i have got this owrking before as well. * So i your case if the concatted results first 3 characters = "Yes" the "Yes" otherwise no.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜