Introduction
Creating APEX Item and Column Properties is an essential skill when building dynamic, user-friendly applications in Oracle APEX. These properties determine how individual items (like form fields) and report columns behave and appear within your app. By setting properties such as default values, validations, read-only status, or conditional visibility, you can fine-tune the user experience and maintain data integrity. Whether you're working on a form or a report, understanding how to configure these settings ensures that your application logic is applied consistently and effectively across different components.
In Oracle APEX, creating and configuring item and column properties is key to building responsive, user-friendly, and secure applications. APEX items represent form fields such as text fields, checkboxes, select lists, date pickers, and more. Column properties apply to reports such as Classic Reports, Interactive Reports, and Interactive Grids. These settings help define how data is displayed, validated, and interacted with across your application.
To create and configure an APEX item, go to:
App Builder > Your Application > Page Designer
In Page Designer, you'll see three panes: Rendering, Layout, and Property Editor.
1. Add or select an item
In the Rendering tree, under a region (like a form region), right-click and choose “Create Page Item,” or select an existing item to modify.
2. Configure item properties using the Property Editor:
-
Name: The internal name of the item (used in PL/SQL or conditions)
-
Type: Choose from Text Field, Select List, Date Picker, etc.
-
Label: User-facing label
-
Value Required: Yes/No, to make it mandatory
-
Default Value: Static value or use a SQL query/PLSQL function
-
Read Only / Disabled: Prevent user edits
-
Source Type / Source Value: Defines where the item gets its value (e.g., DB column, static value, or function)
-
Session State Protection: Optional, restricts manipulation via URL
-
Display Settings: Alignment, width, templates, etc.
3. Add validations and dynamic actions to enhance item behavior:
-
Validations: For required fields, format checks, value ranges.
-
Dynamic Actions: Change other fields, hide/show items, set values, refresh regions, etc., based on user interaction.
To define Column Properties in a report (e.g., Classic Report):
App Builder > Your Application > Page Designer > Select Report Region
1. Select a report column under the region in the Rendering tree.
2. Modify column properties in the Property Editor:
-
Heading: Change the display name
-
Type: Plain Text, Link, Hidden, Display as Image, etc.
-
Alignment: Left, Center, Right
-
Format Mask: For dates, numbers, currency
-
Escape special characters: To allow HTML tags
-
Link target: Add link to another page (detail view or edit form)
-
Conditional Display: Show or hide column based on logic
-
CSS Classes and Styles: Apply custom design using themes or inline CSS
You can also use the Column Attributes section to apply advanced behaviors like:
-
Tooltip text
-
Conditional formatting
-
Aggregation (sum, count) for Interactive Reports or Grids
-
Row highlight rules
Dynamic Properties via PL/SQL or Conditions
You can use conditions or PL/SQL expressions to make properties dynamic. For example:
-
Set Read Only When =
:P1_MODE = 'VIEW'
-
Use a Display Condition like
:P1_ROLE = 'ADMIN'
This makes your application reactive and context-aware, showing or hiding elements based on user roles, actions, or data.
By carefully setting and customizing APEX item and column properties, you ensure that your application's UI is functional, intuitive, and secure. It reduces manual coding, enforces business rules, and enhances the user experience across your entire application.
Example
In Oracle APEX, you can customize how form items and report columns are displayed by using various properties. These properties allow you to modify labels, display values, disable/enable items, manage CSS classes, and determine required fields, among other things.
In this tutorial, we will walk you through how to use the Item Properties and Column Properties in Oracle APEX with practical examples. We'll cover the following properties:
Item Properties:
LABEL
DISPLAY
CHANGED
DISABLED
Column Properties:
HEADING
LABEL
DISPLAY
HEADING_CLASS
COLUMN_CLASS
REQUIRED
Step 1: Understanding Item Properties
When working with form items (such as text fields, drop-down lists, checkboxes, etc.) in APEX, you have several important properties that control their behavior and appearance. Below, we will explain how to use these properties in your application.
1. Item Property: LABEL
Purpose: The LABEL property defines the text label that appears next to a form item (such as a text field or drop-down). This is typically used to explain what the input is for.
Usage: You can set this property when configuring a form item.
Example:
Create an item like Text Field for First Name.
In the Label field, enter "First Name". This will show up next to the input field on the form.
2. Item Property: DISPLAY
Purpose: The DISPLAY property defines the current value that is shown in the form item when the page is rendered.
Usage: This property can be set dynamically using SQL queries or PL/SQL.
Example:
Create a Text Field for First Name.
Set its Value property to SELECT first_name FROM employees WHERE employee_id = :P1_EMPLOYEE_ID.
When the page loads, the first name of the employee with P1_EMPLOYEE_ID will be displayed in the text field.
3. Item Property: CHANGED
Purpose: The CHANGED property indicates whether the value of an item has been modified. It will return "Y" if the value has changed from its default value and "N" if it hasn’t been changed.
Usage: This is useful for validation or to trigger certain actions when a field is edited.
Example:
Create a Text Field for Email Address.
Add the following Dynamic Action:
Event: Change
Action: Display a message if the Email Address has changed.
Condition: CHANGED = "Y"
4. Item Property: DISABLED
Purpose: The DISABLED property controls whether the form item is editable. If set to "Y", the item will be disabled, preventing the user from modifying its value.
Usage: This can be used in scenarios where certain form items should not be modified by the user.
Example:
Create a Text Field for Employee ID.
Set the Disabled property to "Y" for Employee ID, making it non-editable. The value will still be visible, but the user cannot modify it.
Step 2: Understanding Column Properties
When dealing with reports, you can customize the appearance and behavior of columns by setting various column properties. These properties help define the label, heading, required fields, and other visual elements for the columns in your report.
1. Column Property: HEADING
Purpose: The HEADING property defines the column heading text that appears at the top of each column in a report.
Usage: You can set this property to a custom string or use it to include HTML tags or other formatting.
Example:
For a Classic Report, the column First Name can have the heading Employee First Name.
In the Column Attributes section, set the Heading to: <b>Employee First Name</b> (using HTML tags for bold text).
2. Column Property: LABEL
Purpose: The LABEL property defines the text label for each column. If no specific label is set, the column HEADING is used.
Usage: This is often used when you want to provide a different label from the heading for columns.
Example:
For the First Name column in a report, you can set the Label to "Name". The Heading would still be "Employee First Name", but the column would display as "Name" in the report.
3. Column Property: DISPLAY
Purpose: The DISPLAY property controls how the value for a column is displayed in the report.
Usage: This property can be customized using SQL expressions, PL/SQL, or APEX substitution variables to format the data as per the requirements.
Example:
For a Salary column in a report, you can format the display value to show the salary in a specific format (e.g., including currency symbol).
TO_CHAR(salary, '999,999.99')
4. Column Property: HEADING_CLASS
Purpose: The HEADING_CLASS property allows you to add custom CSS classes to the column heading.
Usage: This property is useful when you want to style the column headings with specific CSS rules.
Example:
In the Column Attributes, you can add a CSS class to the HEADING_CLASS property like class="heading-blue".
In the CSS file, define:
.heading-blue {
color: blue;
font-weight: bold;
}
5. Column Property: COLUMN_CLASS
Purpose: The COLUMN_CLASS property lets you add CSS classes to the column cells in a report.
Usage: This property is useful when you want to style the data in a particular column based on certain conditions.
Example:
For the Salary column, you can set the COLUMN_CLASS property to class="salary-column".
Then, in your CSS file, you can define a specific style:
.salary-column {
font-weight: bold;
color: green;
}
6. Column Property: REQUIRED
Purpose: The REQUIRED property determines whether a column in a form is mandatory for users to fill out before submitting the form.
Usage: This property is particularly useful for form items in APEX. If set to "Y", the column is marked as required.
Example:
For a Text Field for Employee ID, set the Required property to "Y" to make it a mandatory field.
The form will display a red asterisk next to the input field to indicate that it’s required.
Step 3: Practical Example – Using Item and Column Properties
Let's combine the item and column properties in a practical example, where we create a form and a report that display dynamic data.
Create a Form Page:
Go to App Builder, and create a new Form page.
Add a Text Field for Employee ID:
Label: "Employee ID"
Display: A SQL query to fetch the employee’s ID based on a session value.
Disabled: "Y" (making it non-editable)
Add a Text Field for Employee Name:
Label: "Employee Name"
Required: "Y" (making it mandatory)
Add a Select List for Job Title:
Label: "Job Title"
Display: A dynamic list query to display job titles.
Required: "Y"
Create a Report Page:
Add a Classic Report to the page.
Set the SQL Query to retrieve employee information:
SELECT employee_id, first_name || ' ' || last_name AS employee_name, job_title, salary
FROM employees
Configure the column properties:
Heading: "Employee Information"
Label: "Full Name"
Column Class: class="employee-column"
Required: "N" (not applicable for reports)
Customize the Salary column:
Heading: "Annual Salary"
Display: Format the salary column as currency using TO_CHAR(salary, '999,999.99').
Styling:
Add custom CSS for the report and form:
.employee-column {
font-size: 14px;
font-weight: bold;
}
Conclusion
Mastering APEX Item and Column Properties allows developers to create more intelligent, interactive, and user-centric applications. From setting required fields and default values to applying dynamic actions and display logic, these properties offer robust control over how users interact with your pages. Taking full advantage of these settings leads to cleaner forms, smarter reports, and a more polished application overall. With these tools at your fingertips, you can deliver powerful APEX solutions that meet both user and business requirements with precision.
No comments:
Post a Comment