Now you have Dynamic Actions, and all the little knobs and wheels show up in the page editor as any other kind of objects. The Apex-team has done a marvelous job of integrating JQuery into the framework.
How Dynamic are Dynamic Actions?
I find that Dynamic Actions are extremely versatile, but you should have some knowledge of JQuery selectors to realise it's full potential.
Invoking Dynamic Actions from Report Columns
In the editor there are no possibility of attaching dynamic actions to tabular forms columns. I wanted to invoke an Ajax-call to commit changes when the user changed a select list in a tabular form, here is a way you can do the same.
If you just want to inspect the code for yourself, I have created a small application you can download from apex.oracle.com: http://apex.oracle.com/pls/apex/p?n=1070334102765726226
First off, create a tabular form, in this example I have a select that uses the APEX_ITEM-api to create application items:
select apex_item.hidden(1, emp.empno) empno , apex_item.display_and_save(2, emp.ename) ename , apex_item.select_list_from_query(3, emp.deptno, 'select dname d, deptno r from dept order by dname', p_item_id => 'empno'||empno) deptno from empNext, create two hidden items, one for the primary key (P1_EMPNO), and one for the changed column value (P1_DEPTNO).
Next, create a Dynamic Action on the page level to invoke the update statement:
Right click Dynamic Actions on the page level, and choose Create
Give the Dynamic Action a name
Set the event to trigger on Change, set Selection Type to JQuery Selector and set JQuery Selector to "select[id^=empno]". This is where we set up the Dynamic Action to fire on every change to all items where the item ID starts with "empno". If you notice the select statement above, I explicitly set the item ID when creating the select lists.
Set the Action to Execute PL/SQL Code, and the PL/SQL Code to the update statement below.
update emp set deptno = :P1_DEPTNO where empno = :P1_EMPNO;
In addition you must set Page Items to Submit with the request (P1_DEPTNO and P1_EMPNO):
Now the Dynamic Action is defined in essence, but there is one piece missing: When the user changes the values of the select list, the new DEPTNO-value and the current EMPNO must be reflected in P1_DEPTNO and P1_EMPNO before the PL/SQL-Code (in this case the update statement) is invoked. This is where the pure genious of the Dynamic Actions come into play; Apex allows you to create additional Actions to execute in the same event.
To set the values of P1_DEPTNO and P1_EMPNO, do the following:
Open the editor for the Dynamic Action
Under True Actions region, click Add True Action
Set the sequence to something lower than the PL/SQL-action (normally this means setting it below 10)
Set the Action to Set Value
Make sure the Fire on Page Load is unchecked
Under Affected Elements, set Selection Type to Item(s) and Item(s) to P1_DEPTNO
Now we have to do the same for P1_EMPNO, this almost the same as for P1_DEPTNO, but we have to get the EMPNO-value from the ID of the triggering element. To achieve this, Click Add True Action, and set it up as seen below:
When you return to the Dynamic Actions editor, this is what the True Actions should look like:
Run the page to check that it works.
A Word of Caution
This was a special and simplified case, normally you should use the native tabular forms functionality in Apex. There are several reasons for this. There is no MD5-checking here (data has been changed by another user), and every little change will result in a round trip to the server (no batch submit and no way for user to cancel changes).
Either way, Dynamic Actions rock!