Creating and managing item and column properties in Oracle APEX is a fundamental skill for developers looking to build efficient and user-friendly applications. These properties control the behavior, appearance, and validation of form items and report columns, allowing you to tailor the user interface to meet specific business requirements. By understanding how to create and configure APEX item and column properties, you can ensure consistency, improve data accuracy, and enhance the overall user experience within your applications.
Creating APEX Item and Column Properties is essential for controlling how data is presented and interacted with in Oracle APEX applications. These properties define the behavior, appearance, validation, and formatting of individual form items and report columns. Proper configuration ensures that your application is user-friendly, consistent, and aligned with your business rules.
To create APEX Item and Column Properties, start by navigating to your application in the Oracle APEX Application Builder. In the Shared Components section, locate the “User Interface Defaults” or “User Interface” settings, depending on your APEX version. Here, you can define properties that apply globally or specifically to tables and columns.
For Item Properties, you specify how form fields behave and appear. Key settings include:
-
Item Type: Choose from Text Field, Select List, Date Picker, Checkbox, Radio Group, etc., based on the data type and user interaction desired.
-
Label: Define a meaningful and clear label that displays next to the item.
-
Default Value: Set a predefined value to simplify data entry.
-
Validation: Add rules to ensure data integrity, such as required fields or format masks (e.g., phone numbers or currency).
-
Appearance: Customize alignment, size, and CSS classes to improve usability and aesthetics.
For Column Properties, which primarily apply to reports, focus on how data is displayed:
-
Display Type: Control whether data appears as plain text, a link, or formatted HTML.
-
Column Heading: Customize the column label for clarity.
-
Formatting: Use format masks for numbers, dates, or currency to ensure readability.
-
Alignment: Set text alignment (left, center, right) to enhance report layout.
-
Conditional Formatting: Apply styles based on data values, such as coloring negative numbers red.
Once properties are defined, they can be reused across multiple pages and components by linking them to the relevant tables or columns. This approach promotes consistency and reduces repetitive setup.
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;
}
In summary, creating APEX Item and Column Properties involves carefully configuring form item behavior and report column display settings through the Application Builder’s UI Defaults or User Interface settings. This process improves data accuracy, enhances user experience, and streamlines application development and maintenance by centralizing control over common UI elements.
Mastering APEX item and column properties enables you to design applications that are both flexible and robust. Properly configured properties reduce manual effort by applying defaults and validations automatically, streamlining development and maintenance. Whether working on forms, reports, or interactive grids, leveraging these properties effectively helps deliver applications that are intuitive, reliable, and aligned with business needs.