Dynamic Actions in Interactive Grid

Dynamic Actions in Interactive Grid

Doing it wrong? (TL:DR Yes)

I have a IG.. on Selection Change i want to change the (Test) Item in Front:

so i did a dynamic action on the IG:

This should mean.. if i change the selection (via mouse i think) and if the COLUMN Name is not null then it fires..

But it fires always TESTWERT1 (but the NAME Column is Not Null)

You can see here:

My new APEX Series ... Doing it Wrong YES/NO?

Here the answer from oracle support:

Hi Thomas!

We have received an answer from the internal team. This is the answer:

"
Yes, this is indeed “doing it wrong”. This is a basic misunderstanding of the difference between a Column and a Column item. The Page Designer UI combines the configuration of both the column and the column item. The column configuration is stuff that applies to the whole column like the Heading, Alignment, Source, and Enable Users To etc. The column item configuration is mostly what is under Settings. It is what you would see if the same item type were used as a page item in a form. The column item is essentially only used for editing but it exists even for non-editable IG regions as well.

The key thing to understand is that there is one column item for a column no matter how many rows the IG report has. Once this is realized it makes perfect sense that on selection change the value of the column item could not possibly reflect the current value displayed in the column cells of the selected rows. (Because there is one column item but the selection can contain 0, 1, or many rows.)

The column item reflects the value of a column cell when that row is active for editing.

In the example app the false branch is always taken because the column item value is always empty string (null). This can be seen by typing the following in the browser console:

apex.item("C65307868152150472121").getValue()

Where did that big number starting with C come from. I found it by viewing the page source and looking at the code where the DA is registered. I recommend that if you are going to be doing anything with a column item from JavaScript or a DA that you give it a name in the Static ID attribute. I recommend using a C_ prefix. So for example C_NAME if the column is called NAME. This will help if you ever need to use apex.item APIs directly or just need to do some debugging.

I would like to think that a number of people on the APEX forum could have explained this if it was asked there. (If he did and didn't get a correct answer please let me know and a pointer to the thread.) I explained the column/column item distinction in my blog article https://hardlikesoftware.com/weblog/2016/06/08/interactive-grid-under-the-hood/ in the section that talks about the flyweight pattern.

If you do want to do something on selection change and what you do depends on the (0 or more) values in a column of the selected rows then you will need to use the model API to access the data in those cells. There are many examples of this on the forum and blogs etc. The model API doc is here: https://docs.oracle.com/en/database/oracle/apex/23.2/aexjs/model.html

Could
the page designer DA configuration not allow you configuring a nonsense combination of settings? I don't think so. APEX DAs are a general facility for handling events by defining a set of actions to run when the event happens. There are many events and many actions. You really need to understand the semantics of the event to know what is reasonable to do as part of the actions and also the DA condition. Maybe some improvements are possible but we need to be very careful to not accidentally prevent someone from doing something unusual but still reasonable.

For example the following will change the app so that the selection change DA takes the true branch:

apex.item("C65307868152150472121").setValue("foo")
"
Kind regards,

Vlad

best wishes tom

The "not" Buggy APP

https://apex.oracle.com/pls/apex/r/tom_sphinx/demo/try-dy-ig?session=106303878510472