In tabular block in Oracle Forms, I want to discriminate between odd records with different color from color of even records alternately so the block in run time look like below image.
The idea of this post is based on my previous post Highlighting Selected Records in Oracle Forms as I use visual attribute for every navigable items in block.
Let's state step by step to do this task on tabular block based on SCOTT.EMP table
Create visual attribute and name it ODD and change its properties as below
Background Color : gray16
Even Visual Attribute
Create another visual attribute and name it EVEN and change its property as below.
Background Color : gray4
You can download sample Form from here
Thanks
Mahmoud A. El-Sayed
The idea of this post is based on my previous post Highlighting Selected Records in Oracle Forms as I use visual attribute for every navigable items in block.
Let's state step by step to do this task on tabular block based on SCOTT.EMP table
1-Create Tabular Block Based on SCOTT.EMP Table
2- Create two Visual Attribute
ODD visual attribute Create visual attribute and name it ODD and change its properties as below
Background Color : gray16
Even Visual Attribute
Create another visual attribute and name it EVEN and change its property as below.
Background Color : gray4
3-Create Stored procedure name it SET_ODD_EVEN_VA
PROCEDURE SET_ODD_EVEN_VA IS LC$CURR_BLOCK VARCHAR2 (80) := :SYSTEM.TRIGGER_BLOCK; LC$CURR_ITEM VARCHAR2 (80); LN$CURR_REC NUMBER; BEGIN LC$CURR_ITEM := GET_BLOCK_PROPERTY (LC$CURR_BLOCK, FIRST_ITEM); LN$CURR_REC := GET_BLOCK_PROPERTY (LC$CURR_BLOCK, CURRENT_RECORD); WHILE (LC$CURR_ITEM IS NOT NULL) LOOP LC$CURR_ITEM := LC$CURR_BLOCK || '.' || LC$CURR_ITEM; DISPLAY_ITEM (LC$CURR_ITEM, CASE (LN$CURR_REC MOD 2) WHEN 0 THEN 'ODD' ELSE 'EVEN' END ); LC$CURR_ITEM := GET_ITEM_PROPERTY (LC$CURR_ITEM,
NEXT_NAVIGATION_ITEM
); END LOOP; END;
4- Cal SET_ODD_EVEN_VA
You should call SET_ODD_EVEN_VA procedures in below triggers at block level
WHEN-NEW-RECORD-INSTANCE
POST-QUERY
5- Write in WHEN-NEW-FORM-INSTANCE trigger at form level the below code
GO_BLOCK('EMP');
EXECUTE_QUERY;
6-Run the form
The form will open and display all records in SCOTT.EMP table and will display tabular block like below imageYou can download sample Form from here
Thanks
Mahmoud A. El-Sayed
Thank you very much, Mahmoud.
ReplyDeleteThanks a lot and I hope my post be useful for you
DeleteGood post for doing highlighting dynamically without defining static item names
ReplyDeleteCan you share an error you faced when compile form?
ReplyDeletenice work...
ReplyDeletei want to write something on how we can buit a oracle report base on excel sheet rather than db table
Gmd Case when support in sql not plsql you can modify that as:
ReplyDeletePROCEDURE SET_ODD_EVEN_VA IS
LC$CURR_BLOCK VARCHAR2 (80) := :SYSTEM.TRIGGER_BLOCK;
LC$CURR_ITEM VARCHAR2 (80);
LN$CURR_REC NUMBER;
BEGIN
LC$CURR_ITEM := GET_BLOCK_PROPERTY (LC$CURR_BLOCK, FIRST_ITEM);
LN$CURR_REC := GET_BLOCK_PROPERTY (LC$CURR_BLOCK, CURRENT_RECORD);
WHILE (LC$CURR_ITEM IS NOT NULL)
LOOP
LC$CURR_ITEM := LC$CURR_BLOCK || '.' || LC$CURR_ITEM;
if (LN$CURR_REC MOD 2) =0 THEN
DISPLAY_ITEM (LC$CURR_ITEM,'ODD');
ELSE
DISPLAY_ITEM (LC$CURR_ITEM,'EVEN');
END IF;
LC$CURR_ITEM := GET_ITEM_PROPERTY (LC$CURR_ITEM, NEXT_NAVIGATION_ITEM);
END LOOP;
END;
Nice Idea !!!, Which is very Efficient Looking of my page....
ReplyDeleteJajakallah..
شكرا مهندس إشتغل
ReplyDelete