Dynamically modifying a data set filter with JavaScript

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.


Comments

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


     


     


     


    Guillaume L.
    Solution Consultant
    OpenText Reporting & Analytics
    http://www.opentext.com
  • 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?


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

  • 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


  • 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
Sign In or Register to comment.