- Inspecting Oracle APEX Packaged Applications (Part 1)
- Inspecting Oracle APEX Packaged Applications (Part 2)
In this last part we are going to create a "Display As" pill button with two options using a List of Values with a custom template to switch between the Cards View created on the previous article and a new Interactive Report.
- Create a button under the new Movies Report region:
- Button Name: ADD_MOVIE
- Label: Add Movie
- Button Position: Next
- Hot: Yes
- Under Template Options:
- Spacing Left: Large
- Action: Redirect to URL
- URL: #0
- Go to Shared Components, List of Values:
- Click on Create
- Create List of Values: From Scratch
- Name: DISPLAY_AS_LOV
- Type: Static
- Display Value #1: Cards View
- Return Value #1: CARDS
- Display Value #2: Report View
- Return Value #2: REPORT
- Create List of Values
- Edit the DISPLAY_AS_LOV list of values:
- Edit the Cards View Display and add the following Template: <span class="t-Icon fa fa-cards" title="#DISPLAY_VALUE#"></span><span class="u-VisuallyHidden">#DISPLAY_VALUE#</span>
- Edit the Report View and add the following Template: <span class="t-Icon fa fa-table" title="#DISPLAY_VALUE#"></span><span class="u-VisuallyHidden">#DISPLAY_VALUE#</span>
- Back on Page 4, create a sub region under the Movies Report region:
- Title: Display As
- Template: Blank with attributes
- Create a page item under the Display As sub region:
- Name: P4_DISPLAY_AS
- Type: Radio Group
- Number of Columns: 2
- Template: Hidden
- Under Template Options:
- Size: Large
- Radio Group Display: Display as Pill Button
- List of Values Type: Shared Component
- List of Values: DISPLAY_AS_LOV
- Display Extra Values: No
- Display Null Value: No
- Default Type: Static value
- Static Value: CARDS
- Escape special characters: No
- Create a new region:
- Name: Report
- Type: Interactive Report
- SQL Query:
- Page Items to Submit: P4_DISPLAY_AS
- Under Template Options:
- General: Show Maximize Button
- Static ID: reportRegion
- Custom Attributes: style="display: none;"
- Region Display Selector: No
- Create a Dynamic Action:
- Name: Toggle Display As
- Event: Change
- Selection Type: Item(s)
- Item(s): P4_DISPLAY_AS
- True Action #1:
- Action: Execute JavaScript
- Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
m.id, | |
m.name, | |
listagg(c.category, ', ') within group (order by c.category) as categories | |
from | |
movies m | |
left outer join movies_categories mc on m.id = mc.movie_id | |
left outer join categories c on mc.category_id = c.id | |
where | |
nvl(:P4_DISPLAY_AS,'X') = 'REPORT' | |
group by | |
m.id, | |
m.name | |
order by | |
m.name asc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($v('P4_DISPLAY_AS') === 'CARDS') { | |
$x_Hide('reportRegion'); | |
$x_Show('cardsRegion'); | |
$x_Show('filterRegion'); | |
$('body').removeClass('t-PageBody--hideLeft').addClass('t-PageBody--showLeft'); | |
apex.region('cardsRegion').refresh(); | |
apex.region('filterRegion').refresh(); | |
} else if ($v('P4_DISPLAY_AS') === 'REPORT') { | |
$x_Hide('cardsRegion'); | |
$x_Hide('filterRegion'); | |
$x_Show('reportRegion'); | |
$('body').removeClass('t-PageBody--showLeft').addClass('t-PageBody--hideLeft'); | |
apex.region('reportRegion').refresh(); | |
} |
That's it. Below are two print screens of the final result: