APEX Training

Friday, 17 May 2013

APEX Tabular Form - Instant Update

Yesterday an interesting question regarding tabular forms, collections and instant updates was asked in the Oracle APEX Forum. This example in my Demo Application shows how you can create a tabular form based on a collection and update this collection instantly. The whole example consists of three main parts:

1. save changes instantly
2. add rows and
3. delete rows

The whole code and the steps required to get it working are explained in the Code section.

Enjoy.


14 comments:

Marko Goricki said...

I have nice plugins (DA and Process) for this but never had time to publish them. Hope I'll manage to do this soon... :)

dlsykes said...

Hi Denes, I have done lots of tabular forms in APEX with different documented approaches. I plan on adopting your approach (page 294 in demo app) for my next project but cannot get this to work with pop-up LOV. It errors out on the set value DA. I am using APEX 4.2.0. Is there a work around or is this a bug in APEX?

Denes Kubicek said...

A popup key lov will need two arrays. Also, the id will start for the first row differently than for a normal select list. I think you can make it work for popup but you need some modifications.

Regards,

Denes

DS123 said...

Hi,

I am using APEX_ITEM.TEXT in the tabular report. It needs to have a default value(This value is obtained by calling a database function.) Later, when user edits the value in the textbox, I need to retain it after page submit. Can you please help?

Dona said...

Hi Denes,
I'm facing a problem in APEX. Please see if you can help. I have posted this in your blog as well.

I have a manual tabular report, with two editable fields(a select list and a text box) and all other columns are apex_item.display_and_save.

On change of the editable fields, these display-only columns's value need to change.[They are being calculated from database functions].

Problem is: When I am setting the values on change of the 2 fields, I am doing so through javascript, using getElementById. But when I am trying to insert these values in database in a Save process, I am doing so through APEX_APPLICATION.G_Fxx (i). And the values are diffrent. APEX_APPLICATION.G_Fxx (i) has the default value stored, while getElementById gives the span id which stores the new value. I want to insert the new value into the table. How can I do this?

I'm not sure if I can use collections here, since in the 'value' attribute of APEX_ITEM.DISPLAY_AND_SAVE, I am calling a database function, which brings the default value for the report column. So I can't put a collection member in there.

Your help will be much appreciated. Thanks!

Denes Kubicek said...

Why don't you create an example? I will try to debug.

Regards,

Denes

Enache Gabriel said...

Hello Denes.
My question will be a bit strange. I have a select list from which the user can select a value. Based on that value a tabular form appear showing records that are compatible with the selected value. I need to check if any of the records from tab form is selected when user press submit button. If no selection is made then the user should get an error. How do i do that?
Thank you.
Gabriel

Denes Kubicek said...

Gabriel,

isn't that something like this:

DECLARE
v_error VARCHAR2 (4000);
BEGIN
IF apex_application.g_f01.COUNT = 0
THEN
v_error := 'No records selected.';
END IF;

RETURN v_error;
END;

?

Denes

mrpele said...

Hi Denes,
I have a problem. The problem is that delete link is not triggering dynamic action although it have set its link attributes as 'id="9" class="delete"'.
So i am confused about 15 and 16 th steps in your code. Can you check these steps?

Denes Kubicek said...

There was an error in the code I posted. I did the correction and you should read it again. The right code is

id="#SEQ_ID#" class="delete"

Regards,

Denes Kubicek

mrpele said...
This comment has been removed by the author.
mirela said...

Hi Denes,

As usual one good solution from you. One question: I'm using APEX 4.0 (I know... not my choice) and I notice that after update and refresh I lose the focus. I can manually set the focus on the next element, but it is not always the user's will. Your application works fine, so any suggestions?

Denes Kubicek said...

So, how do you know what the user wants? Where exactly do you want to focus the cursor?

Denes Kubicek

Mirela said...

Hi Denes,
On the change event is the region refreshed. In APEX 4.0 is the cursor just not focused anymore. I would expect that if the user the "Tab" has clicked that the cursor would be in the next input field. But if he used the mouse, I would expect the cursor to be in that field.
Thanks,
Mirela