This discussion is archived
6 Replies Latest reply: Aug 2, 2012 7:22 AM by evrm RSS

Show/Hide region - only run query when shown?

603257 Journeyer
Currently Being Moderated
Hi,
Just wondering whether this is possible without coding it up manually...? I wan a show/hide region but the report detail is only used now and again and takes a couple of seconds to run. So rather than having it as overhead on every page, I want to have a show/hide region and only run the query if the user selects to show.
I know it can be done by branching to another page but I would like it as a region on the same page if possible.

Regards
John
  • 1. Re: Show/Hide region - only run query when shown?
    evrm Pro
    Currently Being Moderated
    Hi John,

    add a where clause to the report query where you use a bind variable to a page item.
    Set the initial value of page item to some value that causes the report query to return no result.
    Then when the user shows the region change the value of the page item that causes the report query to return the desired result.

    regards,
    Erik-jan
  • 2. Re: Show/Hide region - only run query when shown?
    603257 Journeyer
    Currently Being Moderated
    Sorry, I should have said, I want to do this without a full page refresh.
  • 3. Re: Show/Hide region - only run query when shown?
    Tom Petrus Expert
    Currently Being Moderated
    That is what evrm meant, i believe.
    <ul>
    <li>Create hidden page item, set the value to 0 and 'value protected' to 'No'. eg P1_SHOW_REPORT</li>
    <li>amend the where clause in your report query. eg AND :P1_SHOW_REPORT = 1</li>
    <li>create an extra true action on the dynamic action you use to show the region. Make this a 'Set Value' action, set the item to value 1.</li>
    <li>create an extra true action on the dynamic action you use to show the region. Make this a plsql action, submit the item to the session state (page items to submit). The code can simply be "NULL;".</li>
    <li>create an extra true action on the dynamic action you use to show the region. Refresh the report region.</li>
    </ul>
    This should refresh the region each time it is shown through the dynamic action.
  • 4. Re: Show/Hide region - only run query when shown?
    evrm Pro
    Currently Being Moderated
    Hi,

    my initial answer was based on a full page submit.
    For a partial page refresh I would agree with the answer Tom has made.

    regards,
    Erik-jan
  • 5. Re: Show/Hide region - only run query when shown?
    603257 Journeyer
    Currently Being Moderated
    Hi,
    Thanks for the replies. I have tried the above and got half way but can't quite get it working...

    I have set up the actions and when I click the button I Can see that the item value is set in the session browser. But the region doesn't refresh.
    If I then manually refresh the page then it shows so it is obvously getting the value, it just seems as though the report isn't refreshing. I have enabled PPR.
    I am using a classic report.
  • 6. Re: Show/Hide region - only run query when shown?
    evrm Pro
    Currently Being Moderated
    Hi,

    change the Refresh Region dynamic action to Execute JavaScript Code
    Use this javascript code:
    //Get the region ID of the reports region
    var r = this.affectedElements[0].id.substr(1);
    //Refresh the reports region
    $a_report(r);
    Make sure to set your classic reports region as the affected element.

    regards,
    Erik-jan

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points