Interactive Grid Column Read Only Control

I thought it would be interesting to share my findings on the Read Only setting for Interactive Grid (IG) Columns.

The Read Only attribute has been around for many years – so why write a blog about it in 2018? Well, something has changed with the Read Only attribute for Interactive Grid columns – here is a picture of the setting which you may not have noticed.

The options for the Execute attribute are For Each Row and Once. The documentation says:

If you refer to Columns in your read only condition, you must specify For Each Row in order for the condition to be evaluated for each row of the Interactive Grid. Otherwise, set to Once to evaluate the condition only one time for the region.

But it defaults to Once. Even though the documentation says I must specify For Each Row when I use the Read Only attribute for an IG column and the Execute attribute only appears for IG Columns. It may be a case of changing the default to For Each Row as an improvement for a future release of APEX, but I’m so tempted to break that rule and see what happens.

To start with, I’m going to conform to the documentation and try the For Each Row setting on my IG column. I’m going to set the Type to Always and set the Execute For Each Row on my Commission pct column.

This has worked out rather well; my whole column is now read only and obviously read only because the column has greyed-out. Excellent.

However, you may have noticed that only Job Ids SA_MAN & SA_REP have a value Commission pct. So let’s modify this a bit more to only allow the user to modify the Commission pct for employees with a Job Id of SA_MAN or SA_REP.

For this, I’m going to use this Read Only criteria on my Commission pct column.

When we apply this and try to edit our IG we see this:

As you can see, only some rows are read only. Pretty cool right?

Now let’s try the same thing but change the Execute value from For Each Row to Once

When we apply this and try to edit our IG we see this:

It has partially worked; the Commission Pct column is actually read only, but there are no visual clues here (i.e. the column has not greyed-out) – which is a UX issue for my users.

In fact, this column has changed to Read Only by pure fluke. What actually happens is that when you change Execute to Once, APEX loses all visibility of IG column values. Therefore JOB_ID returns the value NULL once – and since NULL is neither contained in SA_MAN nor SA_REP, it, therefore, meets the read only criteria and subsequently sets the column to read only.

In fact, through several tests of several combinations of the Read Only setting; this really is an undesirable situation and Once should never be used in conjunction with IG columns.

So when do you use Once? Well, it works okay when you are referencing page items; for example, I created a switch (P10_SWITCH) which controls when my Commission pct column is Read Only.

Again this works well – but that visual clue is missing again. For the users, they need this clue.

So, for now, why not always use Execute For Each Row?  Unless things change, I am using Execute For Each Row to keep this as declarative as possible. There is an overhead of using For Each Row…

… but as long as you accept this – then this may be your solution.

It’s always good to keep an eye on any potential changes to this, and other, IG features. However what I wanted to provide you with, in this blog, is an overview of the Execute attribute so that you can understand it a little better and apply it to your applications.

Facebook
Google+
http://www.explorer.uk.com/interactive-grid-column-read-control">
Twitter
LinkedIn

Follow us on twitter

@Explorerukltd

About the Author

Matt Mulvaney

Senior Oracle APEX Development Consultant

Explorer (UK) Ltd - Oracle award winning Platinum Partner

Matt is an experienced APEX solution designer having designed numerous complex systems using a broad range of Oracle Technologies. Building on his previous experience of Oracle Forms & PL/SQL, he is entirely focused on providing functionally rich APEX solutions. Matt promotes APEX as a software platform and openly shares best practises, techniques & approaches. Matt has a passion for excellence and enjoys producing high quality software solutions which provide a real business benefit.

APEX, Blog / Interactive Grid

Featured Posts