Jump to content
We've recently updated our Privacy Statement, available here ×

Default checking of all checkboxes for a Multi-Select Query Input Control


mwarner_2
Go to solution Solved by kkriplani,

Recommended Posts

Is it possible to default check all the checkboxes for a multi-select query input control?  If so, how?

I have a Jaspersoft Server defined input control, and it is a multi-select query.  Say the underlying database query is something like 'select all cities where the temperature yesterday was above 62 degrees'.  The query would have different results every day, which means that I don't know ahead of time what the possible results of that query will be.

As it is now, in Jaspersoft, not selecting any values in a multi-select input control is the exact same thing as selecting all the values.

But the customer wants all the checkboxes for that input control to be checked by default (when they first see the control).

I have not seen any thing in Studio or Server where I can default check the checkboxes for a multi-select query input control.

Thank you.

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

I suppose there are a couple of workarounds, let me list them as follows;
1) either in the default expression of the multiselect parameter you can enter the values as;
    [1,2,3,4,5,6,7,8,9]
    this would check the values in the default expression. Now, Obviously if you have 300 distinct values to be checked you will have to list all of them, which is a bit cumbersome.

2) The Other method is simpler. Declare another parameter as $P{abc} and in its default expression, write;
$P{m_parameter} == "null" ? "select distinct <column> from table" : $P{m_parameter}         [where m_parameter is the multiselect parameter  and column is the values of the multiselect parameter from the table]

The sample query for method 2 would look something like;

Select * from table_2
where $X{IN, <column_2> , ($P!{abc})}


Hope this helps,
KKriplani

Link to comment
Share on other sites

I can't do method 1 because I don't know those values ahead of time (and those values change).  So I am trying to do method 2.

You talk about the query for method 2.  By this you are referring to the JS Server input control query for the multi-select checkbox?

What is table_2, and column_2?

Is $P{abc} defined as a string, or a collection, or as a what?

 

And by doing this method, then all the checkboxes for $P{m_parameter} will be checked (instead of the usual unchecked)???

Link to comment
Share on other sites

Okay.
The answer to your questions are as follows;
1) The query is the main/dataset query and not the input control query. The query just shows how to implement the IN condition and the use of conditional parameters ( to know more, read my answer on this link) in jasperreports. 
2) table_2 and column_2 are just table and column used for the main query (as i stated in point 1 that its just an example).
3) Yes, the conditional parameter ($P{abc}) would be a string while the multiselect parameter would be a collection.

Sorry, for the late response. Let me know if you have any more queries,
KKriplani.  

Link to comment
Share on other sites

  • 4 months later...
  • Solution

Hi,
Okay i seemed to have found a solution, give it a try.
All you have to do is as follows;
1) keep the default expression of the parameter fetching value from multi-select Input control as blank, i.e, insert no values.
2) And keep the multi-select input control as non-mandatory.

The behaviour of multi-select that I observed was, non of the boxes will be checked but the query would pass the value as :
"where 0=0"
That means, all the selections are considered. 

Regards,
KKriplani

Link to comment
Share on other sites

I do not have a resolution to my question.  Wish there were one.  I do appreciate you being the only person to attempt to answer this question.

I down voted your solution because as you said "none of the boxes will be checked".  And my question was about how to check all the boxes.

I would remove my negative vote, but there is no way to reset it back to zero.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...