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

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

  • mwilliamsmwilliams BIRT Guru
    edited July 7, 2014

    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. http://developer.actuate.com/community/forum/index.php?/files/file/785-user-specified-custom-sort-order/


    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited March 19, 2013
    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...
  • mwilliamsmwilliams BIRT Guru
    edited December 31, 1969
    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.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 31, 1969
    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?
  • mwilliamsmwilliams BIRT Guru
    edited December 31, 1969
    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.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 31, 1969
    Thanks....Last example works in my case.
  • edited December 31, 1969
    It seems very complicated
  • 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?

  • 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.

     

    Hope this helps.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • I did look for the ? but this is the query in the dataset:

     

    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

     

    I was expecting to find

    where CLASSICMODELS.CUSTOMERS.COUNTRY = ?

    but where is it?  There are also no Parameters configured in the data set.  It's pure magic ;-).

  • 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:

     

    if (params["Country"] != "All"){

    this.queryText = this.queryText + " and CLASSICMODELS.CUSTOMERS.COUNTRY = '" + params["Country"] + "'";

    }

     

    Sorry about the confusion.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • Now I see it.  Thanks a lot!

  • 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?

  • 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.)

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • Hi,

     

    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?

     

     

      This program cannot display the webpage  
     
      Most likely causes:
    • You are not connected to the Internet.
    • The website is encountering problems.
    • There might be a typing error in the address.
      What you can try:     Check your Internet connection. Try visiting another website to make sure you are connected.     Retype the address.     Go back to the previous page.     More information

     

    Thanks

    UY

    Thanks,

    UY

  • UY, you're talking about the design I attached above?

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • when open the Design & code part it is giving error :

     

    404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

     

     

    please help me . I am looking for this topic .

     

     

    Thanks

    Munish Jindal

     

  • 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.


    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited March 3, 2015

    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".


     


    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


     


    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.

    OR

    Change the default value to an expression "All".

    That looks like it'll do it.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • 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;

    myParameterArray[paramArrayLength] = row["CASE_NAME"]; where CASE_NAME is database field.


     


    Please let me where I have to do link to show all CaseNames in drop down.


     


    Thanks.


  • You need to bind your text box to your parameter data set.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • Thanks for your help.


  • Not a problem at all. Let us know whenever you have questions. :)

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • 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.


     


    Below I am explaining  the same question in other way.


     


    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?


     


    Thanks.


  • 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.


     


    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.


     


    Have you tried adding a Pie Chart to the design?


    Regards,

     

    Jesse Freeman

    Solution Consultant

    OpenText Corporation

    http://www.actuate.com | http://www.opentext.com

     

  • 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.


     


    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.

  • edited March 10, 2015

    I've attached an example that demonstrates having two select elements and a button to trigger rerunning the report with the parameters selected.


     


    This example is a modified version of the original example report Michael attached.


    Regards,

     

    Jesse Freeman

    Solution Consultant

    OpenText Corporation

    http://www.actuate.com | http://www.opentext.com

     

  • It works now and Thanks for your gr8 help. :)


  • You're welcome.


    I'm glad to hear you got it working.


    Regards,

     

    Jesse Freeman

    Solution Consultant

    OpenText Corporation

    http://www.actuate.com | http://www.opentext.com

     

Sign In or Register to comment.