Accessing the row selector of a tabular form
Maybe you already had the "joy" to find out that accessing the "Row Selector" column of an updateable tabular form isn't that straightforward as expected. Because the corresponding g_f01 array isn't indexed by row number as the other column-arrays of the tabular form.
Instead it contains as many values as you have checked rows. The value of the array entry contains the "real" row number for which it has been checked. So you can have the situation that g_f01 has a count of 2, but your g_f02 containing the EMPNO contains 15 rows. In the case if the g_f02 is your "driving" array, because you want to process all the records and only for the checked ones you want to do something special, it can get really challenging for a new APEX programmer (and even for a more experienced one).
That's why I have added new functionality to my Plug & play tabular form handling package, to make accessing the row selector as easy and straightforward as possible.
The package ApexLib_TabForm now contains the additional methods isRowSelectorChecked, setRowSelector. The hasRowChanged has been enhanced to also check for the row selector column.
Let's demonstrate the new functions with an example!
This example demonstrates several features of the ApexLib_TabForm package.
Get the source code from the original posting and try it out!
Instead it contains as many values as you have checked rows. The value of the array entry contains the "real" row number for which it has been checked. So you can have the situation that g_f01 has a count of 2, but your g_f02 containing the EMPNO contains 15 rows. In the case if the g_f02 is your "driving" array, because you want to process all the records and only for the checked ones you want to do something special, it can get really challenging for a new APEX programmer (and even for a more experienced one).
That's why I have added new functionality to my Plug & play tabular form handling package, to make accessing the row selector as easy and straightforward as possible.
The package ApexLib_TabForm now contains the additional methods isRowSelectorChecked, setRowSelector. The hasRowChanged has been enhanced to also check for the row selector column.
Let's demonstrate the new functions with an example!
BEGIN
FOR ii IN 1 .. ApexLib_TabForm.getRowCount
LOOP
IF ApexLib_TabForm.hasRowChanged(ii, TRUE)
THEN
IF ApexLib_TabForm.isRowSelectorChecked(ii)
THEN
callAbc
( pEmpNo => ApexLib_TabForm.NV('EMPNO', ii)
, pEname => ApexLib_TabForm.V ('ENAME', ii)
, pHireDate => ApexLib_TabForm.DV('HIRE_DATE', ii)
);
ELSE
callXyz
( pEmpNo => ApexLib_TabForm.NV('EMPNO', ii)
, pEname => ApexLib_TabForm.V ('ENAME', ii)
, pHireDate => ApexLib_TabForm.DV('HIRE_DATE', ii)
);
END IF;
END IF;
END LOOP;
END;
This example demonstrates several features of the ApexLib_TabForm package.
- With getRowCount you don't have to care that you use the correct g_fxx array to process all records. Remember: If you have a row selector, g_f01 just contains as many records as you have checked values. So you would have to use g_f02 in that case.
- hasRowChanged compares the old- with the new checksum, to verify if the record has been changed. If the new additional boolean parameter pIncludeRowSelector is set to TRUE, the row selector column will also be checked.
- isRowSelectorChecked will return TRUE if the checkbox has been set for that row.
- NV, V and DV to access the column by name. You don't have to worry anymore that when somebody is resorting the columns of the report, that it will break your code. This functions will also return the value of the column with the correct PL/SQL data type by applying the format mask which is defined for the column.
Get the source code from the original posting and try it out!
Labels: ApexLib, tabular form







9 Comments:
Hi Patrik
We have a problem with master detail forms using APEX.
In our master form, we have txn_id as primary key & the detail table is having (txn_id,sub_txn_id) as primary key.If i use the wizard & create master detail, it doesn't work as expected.Both the P.K.s are sequence generated. The trouble seems to be with the restrictions of PK using master detail. Do you have any idea which can be helpful.
By
Sandeep, at 18 December, 2006 14:43
should your example read:
pEmpNo => ApexLib_TabForm.NV('EMPNO',ii);
Wrong Number of Variables in 0.16
Also does this package work also for row selctor in reports (Updatable SQL) where the primary key is hidden with no refernce to the underlying schema, table, and column?
Regards,
Mike
By
Michael, at 11 January, 2007 05:18
Hi Mike,
thanks! I have corrected the example.
The package will work for an updateable report where the primary key is hidden, because the APEX row selector doesn't store the primary key as checked value, it just stores the record position (1-9999) on the screen. So when you loop through the records from 1 .. ApexLib_TabForm.getRowCount the ApexLib_TabForm.isRowSelectorChecked(ii) function will just check if the row selector is checked for the passed record number (ii). No PK, ... involved in that.
Hope that helps you
Patrick
By
Patrick Wolf, at 11 January, 2007 09:00
Hi Patrick,
Is there a way to automatically check the row selector of just the newly added row? If a user clicks on the "Add Row" button, it should add a new row and the row selector should alse is checked. I have no problem with adding new rows i just need to set the row selector automatically. I would really appreciate your help!
Thanks!
Marilyn
By
Marilyn, at 27 May, 2008 20:30
Marilyn,
I have answered your question on the related OTN thread
Patrick
By
Patrick Wolf, at 27 May, 2008 22:53
Hi Patrik
I am unable to download apex_lib and the how-to-integrate document. Can you please help.
Regards
Swapnil
By
Anonymous, at 16 June, 2008 18:08
Swapnil,
what exactly doesn't work? Just tried it and it worked fine. Send me an e-mail if you still have problems.
Patrick
By
Patrick Wolf, at 16 June, 2008 21:11
Hi Patrik,
I'm trying to use ApexLib_TabForm.NV() on a hidden column, yielding ORA-20555 The column 'SEQ' does not exist. Changing column to display as text results in same behavior. Can you suggest a solution?
Thanks,
Derek
By
Derek, at 17 June, 2008 23:45
Resolved.... Somehow making it a text field and then hiding it shook the problem loose.
By
Derek, at 17 June, 2008 23:53
Post a Comment
<< Home