⚡ Oracle APEX Interactive Grid: Dynamically Set Columns Read-Only Using the Readonly Attribute

🚩Introduction 

  • In modern Oracle APEX applications, controlling how users interact with data is very important. A useful feature is making a column in an Interactive Grid read-only based on the value of another column in the same row.

  • With this approach, when a specific column holds a particular value, such as "Manager" in the Job column, the related checkbox or flag column becomes read-only automatically. This keeps data accurate, prevents unwanted changes, and makes the application smarter and easier to manage.

📑 Why This Approach Is Needed

In Oracle APEX applications, not all users or roles should be allowed to edit every field in an Interactive Grid. Allowing unrestricted edits can lead to data issues, incorrect entries, and confusion in the application.

Making a column conditionally read-only becomes important when:

  • Certain rows have special roles or statuses that should not be changed
  • Data accuracy needs to be maintained based on business rules

  • Users should only edit fields that are relevant to their row's context

  • Preventing accidental changes to restricted records is important

  • A controlled and reliable editing experience is needed

This approach helps maintain data integrity, reduces errors, and makes the overall application more reliable while keeping the logic simple and well integrated in Oracle APEX.

👉 Use Case: Making an Interactive Grid Column Read-Only Based on Another Column Value in Oracle APEX

In Oracle APEX, users working with an Interactive Grid may need certain columns to be restricted based on the value of another column in the same row. For example, when the Job column holds the value "Manager" the checkbox or flag column for that row should automatically become read-only, while rows with other job values remain editable.

In this blog, we will see how to implement this feature in Oracle APEX using the readonly attribute with JavaScript. It helps control column editability at the row level, keeps data consistent, and provides a smarter and more controlled editing experience for users.

Step 1: 

In the page designer, create a region and change the type to Interactive Grid and copy paste the below SQL code.

 Step 2: 

Click on the Attributes tab of the Interactive Grid and click on the the Enabled property under the Edit section.

Step 3: 

Click on the Flag column and change the type to Check Box. In this blog, we are going to make this checkbox readonly based on the Job Column.


Step 4: 

When the Job column value is "MANAGER", then we will make the checkbox read-only. To do so, under the property, navigate to the Read Only section and select the Type as  Expression and enter the PLSQL Expression as :JOB = 'MANAGER' and Select the For Each Row from the Execute property.

Step 5: 

Now save and run the page, you will see the Interactive Grid. Now click on the check box, it will be checked for the Job value with PRESIDENT and click on the check box, it will be in readonly for the Job value MANAGER.


🔥 Conclusion

Thus, in Oracle APEX, making an Interactive Grid column read-only based on another column value using the readonly attribute and JavaScript provides a simple and effective way to control data editing. This ensures that restricted rows, such as those with the "Manager" job value, are protected from unwanted changes while keeping other rows fully editable and easy to use.

Comments

Popular posts from this blog

🔍 Extending Smart Search Filter for Multiple Regions

📌Track Active Tab switch in Region Display Selector without any plugins

💡 Designing Dynamic QuickPicks in Oracle APEX