HTML button that calls beforeOpen() DataSet method
<p>Hi everyone,</p>
<p> </p>
<p>Im building a report that has some textboxes filters in it. Initially the report is created without any filter. My idea is that when the user clicks on a button, the filters are applied with the Textboxes that he filled and the Query is changed to have those "wheres". The concept that i am using is the following, which was answered in another topic: </p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;"> </p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">Yes, you can do that. If the parameter is optional you can't use the Dataset Parameter (with a ? in your query), because it will be null. Instead you have to modify your query using JavaScript.</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">Create a Report Parameter like usual, in this case 'stud_no'. Then add a comment in your SQL that you are reasonably sure is unique, I use something like --$stud_no$, wherever you want your clause inserted.</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">Then add a script like this to your Data Set, in beforeOpen:</p>
<p>if (params["stud_no"].value){<br>
this.queryText = this.queryText.replace("--$stud_no$", "and stud_no = " + params["stud_no"]);<br>
}</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">This replaces the comment with the clause when the parameter has a value. You can use regex in the search string, and then you can also insert it multiple places if you want.</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;"> </p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">So I have two questions:</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">1- How can I make a Parameter receive the value of a Textbox? ;</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">2 - How can i make that the button calls beforeOpen() and apply the changes ?</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;"> </p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">Im sending what I have until now with my report, which is pretty much nothing at all because Im new with BIRT.</p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;"> </p>
<p style="font-size:15px;color:rgb(36,39,41);font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;">Thank you.</p>