Jump to content

BIRT Developer Center Download


Photo
- - - - -

Dynamically modifying a data set filter with JavaScript

filter JavaScript dynamically modifying

  • Please log in to reply
6 replies to this topic

#1 mogwai

mogwai

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 22 October 2014 - 12:35 AM

I have a data set created by a lengthy union of half a dozen tables.

I want the user to be able to filter this data set on multiple or all districts.

I created a multi-select report parameter which allows me to select several districts.  This works fine.

I would like to add the default value 'All' so that the filter actually doesn't filter.

 

Is there a way to do this?

 

I was hoping there was way to modify the filter using JAvaScript in the BeforeOpen event script.

Another option would be to use JavaScript in the actual filter condition itself but I'm not sure which JavaScript would do the trick.

 

Modifying the query text is too cumbersome because I would have to parse every table union.



#2 GLO_FR

GLO_FR

    Senior Member

  • Members
  • 428 posts

Posted 22 October 2014 - 01:20 AM

Hi,

 

why didn't you use the filter option in your union dataset ?

 

If the filter has to be dynamic, type everything in the function windows with some JS code and set the result to true or false.

 

 

 

Attached Files


Guillaume L.
Solution Consultant
OpenText Reporting & Analytics
http://www.opentext.com

#3 mogwai

mogwai

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 22 October 2014 - 01:35 AM

I'm not sure how this would work.  Currently I have a filter on the union data set.  It is

 

row["district_ID"] In params["geoScope"].value

 

geoScope is a dynamic multi-select report parameter listing all the districts

 

This works fine but to get all the districts I must select them all.

 

What I am trying to accomplish is a filter that does this:

 

if params["geoScope"].value == "All" don't apply any filter

else apply filter row["district_ID"] In params["geoScope"].value

 

How can I do this using the data set filter option?



#4 GLO_FR

GLO_FR

    Senior Member

  • Members
  • 428 posts

Posted 22 October 2014 - 01:46 AM

Ok,

 

So write some JS like this in the function window (not tested yet)

if(params["geoScope"].value=="All") true
else if (params["geoScope"].value.join('/').search(row["district ID"])) > -1 true
else false

and set the operator in the filter window to "is True"


Guillaume L.
Solution Consultant
OpenText Reporting & Analytics
http://www.opentext.com

#5 mogwai

mogwai

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 22 October 2014 - 05:03 AM

Thanks Guillaume.  This works  beautifully.  I couldn't get

 

if(params["geoScope"].value=="All") true

 

to work for some reason.  When I made it

 

if(params["geoScope"].value.join('/') == "All") true

 

It worked.  Following your example, my final solution was

 

if(params["geoScope"].value.join("/").search("All") > -1) true

 

because it is multi-select and if someone selects All as well as another district, I take it 'All' overrules.

 

Thanks again.


  • Sai Krishna likes this

#6 GLO_FR

GLO_FR

    Senior Member

  • Members
  • 428 posts

Posted 22 October 2014 - 05:17 AM

As I said, the code wasn't tested  :unsure: , but the idea was there !

Great job mogwai !


Guillaume L.
Solution Consultant
OpenText Reporting & Analytics
http://www.opentext.com

#7 Sai Krishna

Sai Krishna

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 15 August 2017 - 01:14 AM

Thanks Guillaume.  This works  beautifully.  I couldn't get

 

if(params["geoScope"].value=="All") true

 

to work for some reason.  When I made it

 

if(params["geoScope"].value.join('/') == "All") true

 

It worked.  Following your example, my final solution was

 

if(params["geoScope"].value.join("/").search("All") > -1) true

 

because it is multi-select and if someone selects All as well as another district, I take it 'All' overrules.

 

Thanks again.

 

Thanks Guillaume.  This works  beautifully.  I couldn't get

 

if(params["geoScope"].value=="All") true

 

to work for some reason.  When I made it

 

if(params["geoScope"].value.join('/') == "All") true

 

It worked.  Following your example, my final solution was

 

if(params["geoScope"].value.join("/").search("All") > -1) true

 

because it is multi-select and if someone selects All as well as another district, I take it 'All' overrules.

 

Thanks again.

Hello i too have this same issue. But here instead of Database i am using excel sheet. Could you please help me how to disable the filter when the value was not given to the prompt. Because it was taking the value as null and displaying 0 records


Thanks & Regards,
Sai





Also tagged with one or more of these keywords: filter, JavaScript, dynamically modifying