Faceted Search was introduced in APEX 19.2 allowing users to filter information easily and intuitively by selecting the options in each facet. For APEX 20.2 the APEX Development Team has included great enhancements to this region. Let's explore them.
This feature allows developers to include a chart for each facet in the Faceted Search page. When the user clicks on the Show Chart button, the chart displays the facet value counts for that specific facet. Users can choose between a bar (by default) or a pie chart. Keep in mind that region level Show Counts attribute must be on for Show Charts to have any effect.
Some of the new region attributes are:
- Show Charts. Available options include:
Popup: A Show Chart button is added to the facet header. When users click the button, it displays the chart in a non-modal dialog.
No: Showing the chart is disabled in general.
Selector: A selector is required on the page where charts will be added. This allows showing multiple charts in the same region.
- Charts Selector. This is the selector of an element on the page where the Faceted Search region will display facet charts. This attribute is available when Show Charts is selected as Selector.
- Display Chart for Top N Values. Provide the number of values to display in the chart for each facet. A value of 10 means that the facet charts will show the first 10 items. When Sort By Top Count is on these are the top values, based on occurrence counts. The default value is 10.
- Show Chart. Specify whether to show the count of occurrences of the list entries as a chart. This attribute only applies if the region attribute Show Charts is equal to Popup or Selector.
- Show Chart Initially. Specify whether the chart is being displayed initially. This attribute only applies if the region attribute Show Charts is equal to Selector.
This feature was created to support tables that contain multiple Boolean type columns. You can create checkbox facets for each of these columns and those can be grouped so that it looks like a single facet.
Let's see how to customize and take advantage of these new attributes.
Create a Faceted Search page
- Navigate to your application and click Create Page.
- Select Report and click Next.
- Select Faceted Search and click Next.
- Enter the name of your page, select the breadcrumb and click Next.
- For navigation menu, create a new navigation menu entry and click Next.
- Select the source of your data. For this example, I'm using the local table EMP, to which I have added these "flags" columns:
- For Display As, select Report.
- Lastly, select the facets you need to include in the report. Scroll down to see the full list of facets.
In addition, if the wizard doesn't suggest any column, click the Refresh button to provide recommendations.
- Click Create.
When you run the page initially, you will notice the Show Chart buttons at the header of the facets:
By clicking on Pie Chart, you can change the type of char for the same facet.
Customize the Faceted Search page
Users see charts in a non-modal dialog by default, by clicking each button they can see the information as an individual chart and when users select other facet values the opened chart is updated in real time. But there's another way to view charts, such as a dashboard mode, where multiple charts can be shown in the same region. To enable that option:
- Drag a new Static Content region and drop it after the Button Bar region.
- For name, enter Dashboard.
- For text, enter:
- Navigate to the attributes of the Faceted Search Region. In this version, you will find attributes in the third panel (at the right).
- For Show Charts, select Selector.
- For Charts Selector, enter the id selector. In this example, I've entered #Dashboard.
- Navigate to the Dashboard region and click on Template Options.
- For General, check the option: Remove Body Padding.
- For Header, select Hidden.
- For Style, select Remove UI Decoration.
- Save changes.
When you run the page, you can click as many charts as you need and those are going to be displayed as a dashboard on the page.
Now, let's focus on the facets. At the moment I have four facets: Department, Salary, Manager, and Job. But remember that this particular table has some "flags" columns, which are characteristics of the Employee: Remote Worker, Able to Travel and Paid Leave. While it is possible to create a facet for each one, it is preferable to include all these characteristics in only one facet as a facet group. Let's take advantage of this feature below.
- Navigate to Faceted Search region.
- Right-click on Facets and select Create Facet Group.
- For Label, enter Characteristics.
- Navigate to the new checkbox created.
- For Name, enter PX_REMOTE_WORKER.
- For Settings, select Custom.
- For Checked Value, enter YES.
- For Database Column, enter REMOTE_WORKER_YN.
- For Data Type, select VARCHAR2.
- Create a new checkbox for Able to Travel and Paid Leave columns, using the following attributes:
||Able to Travel
10. Save changes.
Let's run the page to see the new facet on the page:
This facet also includes a chart, which can be shown as a bar or pie chart.
Review some of these enhancements in the following video:
- To sort the information by a specific column, such as the name of the employee, use the following declarative method:
- Navigate to the Classic Report region.
- Navigate to the column, in this case, ENAME.
- In the attributes of the column, navigate to Sorting.
- For Default Sequence, select 1.
- For Direction, select Ascending.
- Save changes.
- If you make changes on Show Chart Initially or Display Chart for Top N Values attributes, you would need to reset the report or end the browser session to take effect when you run the page. The reason is that the chart configuration is stored in browser session storage and that takes precedence over a change in configuration.
The wizard generates a Reset button on Faceted Search pages, so that's the easiest way to see the changes in your page.
Additionally, you can add your own link with cache-control RR (Reset Report). This will clear out all Faceted Search settings saved in browser session storage.
The Faceted Search feature has been enhanced since APEX 19.2, allowing developers to include more features to their applications in a declarative way, without adding hundreds of lines of code.
From the user's point of view, it's the easiest and intuitive way to filter data, including finding relevant business data in a visual and interactive way.
Note: Please remember that the value "X" in "PX_ITEM" is dependent on the APEX page you're working on.