Dynamic Action with Button to create Hide / Show region
629166Jan 21 2011 — edited Jan 25 2011I've already solve this, but I'm hoping to hear of a better solution, or give anyone needing the same thing a time saver.
My situation:
I need to create a hide/show region which would use a button to hide/show a region. I could not do a page submit (for reasons not relevent to this).
I am using Apex 4.0. I wanted to use as much native functionality as possible and keep it simple. I actually used this to mimic the SAVE REPORT feature
in an IR, but when a user clicks the SAVE REPORT button (SHOW in my example below) it opens a nearly identical form for saving a report. However
unlike the built in SAVE REPORT I wanted to save the actual data set of the report to a table.
Thus I used the new Dynamic Actions with 2 simple buttons with Javascript to make this a nice solution. Please let me know if the directions are not clear.
Whenever I figure something out on Apex I'm going to try to post complete step by step.
So, using Dynamic Actions here is my solution. This will allow you to click a button to SHOW a region, click another button to HIDE the region and it's really painless.
1) Create a TEXT FIELD page Item (P10_DA_REGION_HS. Put this Item in a region that will not be hidden so you can see the value. (later change it a hidden item). There is nothing fancy
to this page item, just a varchar or number and that's it. Give a name, and leave the rest defaults. (it'll hold a 0/1, yes/no type value)
2) Create any type of region to test the HIDE/SHOW:
name: REGION_HIDE_SHOW (no doesn't need to be a hide show/any region works)
3) Create a DYNAMIC ACTION. (This is a new feature in Apex 4). It's on the lower left hand side of the app builder screen, just below Processes.
Name: P10_DA_TEST
Sequence: take the default
Event: Change
Selection Type: Items(S)
Item: P10_DA_REGION_HS (this is the item that you created to hold a YES/NO, 0/1, etc
Condition: equal to
Value: 0 (basically if the value of P10_DA_REGION_HS is 0, Region is shown, if other then is HIDE)
True Actions:
Sequence: take default
Action: SHOW
Fire when event result is: TRUE
Fire on page load: YES
Selection type: REGION (this means I'll be hiding and showing a region, can set this to items as well)
Region: REGION_HIDE_SHOW the region that will be SHOW or HIDE
False Actions:
Sequence: take default
Action: HIDE
Fire on page load: YES
Selection type: REGION
Region: REGION_HIDE_SHOW (Put your region here)
Event scope: left it to bind
5) Create 1 button to SHOW, nothing fancy, just a regular template button.
Put the button in a region that will not be hidden.
Action when button clicked
Action: Redirect to URL
URL Target: javascript:$s('P10_DA_REGION_HS',0); --this will set the page Item created above to 0 to show the region
6) Create 2nd button to HIDE, nothing fancy, just a regular template button.
Put the button in a region that will not be hidden
Action: Redirect to URL
URL Target: javascript:$s('P10_DA_REGION_HS',1); --this will set the page Item created above to 1(or anything other than 0) to hide the region
Test, modify and post improvements.
Hope this saves someone some time. Cheers.
Update: I found this does NOT work in Firefox 3.6.13. I have NOT investigated further since the powers that be dictate IE (7.0.5730.13)
Not sure about Opera or anything else.