Adding new drop down in birt report and changing query parameter based on value from dropdown

Sphand
edited February 11, 2022 in Analytics #1
I want to add new drop down in birt report which contain hard coded(numeric) values and user can select any value which decide number of records to display in query

And also how to access report parameter in html script?
«13

Comments

  • mwilliams
    edited July 7, 2014 #2
    <p>This isn't exactly what you're looking for, but it's an example showing the use of user entered information inside the design, then being able to rerun the report with that info. This should help you get what you're wanting. If you need a more exact example, let me know. <a data-ipb='nomediaparse' href='http://developer.actuate.com/community/forum/index.php?/files/file/785-user-specified-custom-sort-order/'>http://developer.actuate.com/community/forum/index.php?/files/file/785-user-specified-custom-sort-order/</a></p&gt;
    Warning No formatter is installed for the format ipb
  • Sphand
    edited March 19, 2013 #3
    Actually I already added drop down using html script:
    <property name="contentType">html</property>
    <text-property name="content"><![CDATA[<head>
    <script>
    populateTotalBalances();
    function populateTotalBalances(obj)
    {
    var selIndex = obj.selectedIndex;
    var balance = obj.options[selIndex].text;
    alert(balance);
    }

    </script>
    </head>
    <body>
    <form name="myForm">

    <select id='totalBalancesDropDown' name='balance' onchange="javascript:populateTotalBalances(this)" style="width:40px;">
    <option>1</option>
    <option>5</option>
    <option>10</option>
    </select>

    </form>


    But now I need one report parameter(no. of record to display)in populateTotalBalances function which set 5 by default and that value will change based on value selected in drop down by user.

    Can I pass it in 'populateTotalBalances(this)'?

    It will be better if you can give me more exact example because I am new in birt report.

    thanks...
  • mwilliams
    edited December 31, 1969 #4
    Sorry for not asking before. What's your BIRT version?

    If you have a report parameter that you need to pass to the list as the default value, you can access report data, in <value-of> tags. Like, <value-of>params["myparam"]</value-of> would return the current value of the report variable, so you could set the default.
    Warning No formatter is installed for the format ipb
  • Sphand
    edited December 31, 1969 #5
    Birt version is '3.2.22' . And how to change query parameter value based on value selected in drop down and then reload the report with that value?
  • mwilliams
    edited December 31, 1969 #6
    Take a look at this report. The default value is set in the onCreate of the text box, by adding the selected=selected to the currently selected value. Onchange, the function to load the report is called. It changes the url of the page to have the new parameter value.

    Hope this helps.
    Warning No formatter is installed for the format ipb
  • Sphand
    edited December 31, 1969 #7
    Thanks....Last example works in my case.
  • messiii
    edited December 31, 1969 #8
    It seems very complicated
  • <p>This works beautifully Michael,  but I can't find where you have set the filter.  It isn't on the dataset, table or group.  Where is it?</p>
  • <p>I use a dataset parameter to limit the query.  If you look at the query, the '?' is a marker that creates a dataset parameter that I link to the report parameter.</p><p> </p><p>Hope this helps.</p>
    Warning No formatter is installed for the format ipb
  • <p>I did look for the ? but this is the query in the dataset:</p><p> </p><p>select CLASSICMODELS.CUSTOMERS.COUNTRY,
    CLASSICMODELS.CUSTOMERS.CUSTOMERNAME,
    CLASSICMODELS.PAYMENTS.CHECKNUMBER,
    CLASSICMODELS.PAYMENTS.PAYMENTDATE,
    CLASSICMODELS.PAYMENTS.AMOUNT
    from CLASSICMODELS.CUSTOMERS,
    CLASSICMODELS.PAYMENTS
    where CLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER = CLASSICMODELS.PAYMENTS.CUSTOMERNUMBER</p><p> </p><p>I was expecting to find</p><p>where CLASSICMODELS.CUSTOMERS.COUNTRY = ?</p><p>but where is it?  There are also no Parameters configured in the data set.  It's pure magic ;-).</p>
  • <p>Ha.  My mistake.  I have two reports in 3.7 named similarly.  I looked at the wrong one.  I have ListBoxParameterInReport and ParameterListBoxInReport.  Weird.  Anyways, looking at the correct report, there is a beforeFactory script in the dataset that adds the appropriate line to the queryText:</p><p> </p><p><strong class='bbc'>if</strong> (params["Country"] != "All"){</p><p><strong class='bbc'>this</strong>.queryText = <strong class='bbc'>this</strong>.queryText + " and CLASSICMODELS.CUSTOMERS.COUNTRY = '" + params["Country"] + "'";</p><p>}</p><p> </p><p>Sorry about the confusion.</p>
    Warning No formatter is installed for the format ipb
  • <p>Now I see it.  Thanks a lot!</p>
  • <p>How could the scripts be changed to allow the selection of multiple countries? Changing the select to multiple is straightforward, but how to pass multiple selected values to the filter?</p>
  • <p>For the report's query to pull the multiple values, you'd just need to pass the selected values as a comma separated string to the report and change the query to use IN ('val1','val2',etc.)</p>
    Warning No formatter is installed for the format ipb
  • <p>Hi,</p><p> </p><p>I am getting the below IE error while trying to select the values in the drop down list on IV(web viewer). Any ideas as to why?</p><p> </p><p> </p>   This program cannot display the webpage   <div> </div>   Most likely causes: <ul class='bbc'><li>You are not connected to the Internet. </li><li>The website is encountering problems. </li><li>There might be a typing error in the address.</li></ul>   What you can try:     Check your Internet connection. Try visiting another website to make sure you are connected.     Retype the address.     <span><a>Go back to the previous page.</a></span>     <a></a> <span><a>More information</a></span> <p> </p><p>Thanks</p><p>UY</p>
    Warning No formatter is installed for the format ipb
  • <p>UY, you're talking about the design I attached above?</p>
    Warning No formatter is installed for the format ipb
  • <p>when open the Design & code part it is giving error :</p><p> </p> 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.<p> </p><p> </p><p>please help me . I am looking for this topic .</p><p> </p><p> </p><p>Thanks</p><p>Munish Jindal</p><p> </p>
  • <p>Ah. I see the URL higher up in the post. It had a link pointing to the old devshare. I have updated the link to the post in the new devshare. Sorry for any inconvenience.</p>
    Warning No formatter is installed for the format ipb
  • mishrasanju76
    edited March 3, 2015 #20
    <p>Hi, I have gone through ListBoxParameterInReport.rptDesign to add drop down and changing query parameter based on value from dropdown. I am trying to use same concept in my code but I am getting error "org.eclipse.birt.report.engine.api.impl.ParameterValidationException: Required parameter CASE_NAME is not set".</p>
    <p> </p>
    <p>Can you please help me that where I set the value?I am attaching my report for reference. I am using BIRT 4.4.1</p>
    <p> </p>
    <p>Thanks
  • Open up your parameter in the data explorer and choose the drop down next to your parameter default value and choose the "constant" option.<br><br>OR<br><br>Change the default value to an expression "All".<br><br>That looks like it'll do it.
    Warning No formatter is installed for the format ipb
  • <p>Thanks, Now error has gone but I can see only Áll value in drop down. While I have modified onFetch script for ParameterDS as paramArrayLength = myParameterArray.length;<br>
    myParameterArray[paramArrayLength] = row["CASE_NAME"]; where CASE_NAME is database field.</p>
    <p> </p>
    <p>Please let me where I have to do link to show all CaseNames in drop down.</p>
    <p> </p>
    <p>Thanks.</p>
  • You need to bind your text box to your parameter data set.
    Warning No formatter is installed for the format ipb
  • <p>Thanks for your help.</p>
  • Not a problem at all. Let us know whenever you have questions. :)
    Warning No formatter is installed for the format ipb
  • <p>I am able to add  drop down in birt report and filter the value in table as per drop down selection. My requirement is to create PIE CHART as per drop down selection. Can you please provide me any example where to populate PIE CHART as per drop down selection? It will be greate help.</p>
    <p> </p>
    <p>Below I am explaining  the same question in other way.</p>
    <p> </p>
    <p>I want to add new drop down in birt report which contain values and user can select any value which decide number of records to display in query And also how to access report parameter in html script to show PIE CHART?</p>
    <p> </p>
    <p>Thanks.</p>
  • <p>From what I can tell, your drop down is triggering a function to rerun the report and passing the value to the CASE_NAME parameter which is in turn applied into the query for the data set.</p>
    <p> </p>
    <p>As such, the data set should already be filtered which means you should be able to just add a Pie Chart and create it normally since your filtering is all happening at the Data Set level.</p>
    <p> </p>
    <p>Have you tried adding a Pie Chart to the design?</p>
    Warning No formatter is installed for the format ipb
  • <p>Yes, It works fine with some changes. I am looking one more help, need 2 drop down and populate the data as per both drop down selection. I am trying to do but as per selection of only first drop down, event is fired and gettign error. Need to populate both drop down and one button like OK and when user will click on OK then query will execute.</p>
    <p> </p>
    <p>Like 2 drop down 'Year ' and 'TASK NAME' ,Select both drop down and clicks on OK button. Please share with me if you have any example like same.</p>
  • JFreeman
    edited March 10, 2015 #29
    <p>I've attached an example that demonstrates having two select elements and a button to trigger rerunning the report with the parameters selected.</p>
    <p> </p>
    <p>This example is a modified version of the original example report Michael attached.</p>
    Warning No formatter is installed for the format ipb
  • <p>It works now and Thanks for your gr8 help. :)</p>
  • <p>You're welcome.</p>
    <p>I'm glad to hear you got it working.</p>
    Warning No formatter is installed for the format ipb