I have tabular block in Oracle Forms, one of block columns is check-box.
The Requirement :
User needs when he checks Check-box, Form should highlight entire record background by another different color like this image
Let's Now begin to create this issue.
1-Create Tabular Block Based on SCOTT.EMP Table
2-Add Non Database Item( check-box)to EMP Block
Change properties of new item as belowNAME: SELECTED
Item Type: Check Box
Value when Checked: Y
Value when Unchecked: N
Check Box Mapping of Other Values: Not Allowed
Initial Value: N
Database Item: No
Width: 14
Prompt: Selected
3- Create Visual Attribute to use it in highlighting entire selected record.
Create visual attribute and name it SELECTEDchange properties of it as below
Background Color : r0g88b75
Create another visual attribute and name it UNSELECTED and don't change any property of it.
4-Create Stored procedure name it SET_HIGHLIGHT to call it to set highlighting
PROCEDURE SET_HIGHLIGHT (IN_SELECTED VARCHAR2)
IS
LC$ITEM VARCHAR2 (255);
LC$NAVIGABLE VARCHAR2 (10);
BEGIN
LC$ITEM := GET_BLOCK_PROPERTY (:SYSTEM.TRIGGER_BLOCK, FIRST_ITEM);
WHILE LC$ITEM IS NOT NULL
LOOP
LC$NAVIGABLE := GET_ITEM_PROPERTY (LC$ITEM, NAVIGABLE);
IF LC$NAVIGABLE = 'TRUE'
THEN
IF IN_SELECTED = 'Y'
THEN
SET_ITEM_INSTANCE_PROPERTY (LC$ITEM,
CURRENT_RECORD,
VISUAL_ATTRIBUTE,
'SELECTED');
ELSE
SET_ITEM_INSTANCE_PROPERTY (LC$ITEM,
CURRENT_RECORD,
VISUAL_ATTRIBUTE,
'UNSELECTED');
END IF;
END IF;
LC$ITEM := GET_ITEM_PROPERTY (LC$ITEM, NEXT_NAVIGATION_ITEM);
END LOOP;
END;
5- Write Code in WHEN-CHECKBOX-CHANGED in Check-box item "SELECTED"
SET_HIGHLIGHT(:EMP.SELECTED);
6- Write in WHEN-NEW-FORM-INSTANCE trigger at form level the below code
GO_BLOCK('EMP');
EXECUTE_QUERY;
7-Run the form
The form will open and display all records in SCOTT.EMP table and when you select check box entire record is highlighted and if deselect check-box highlighting is removed.You can download sample Form from here
Thanks
Mahmoud A. El-Sayed
you are sharing best coding behind oracle forms, i got something knowledge about it. you update regularly. Thanks a lot...
ReplyDeleteThanks a lot
DeleteThank you very much....
ReplyDeleteHi Mahmoud!!
ReplyDeleteGreat wOrk You have Shared..
i Really appriciate it :-)
i have a Tiny Little question Bro,
when i implemented the abOve example,
at runtime it shOwed Me an error that
"ambigous V_no" (V_no is Primary key of My data Block)
can You plz Help Me out??
Thanx in advance :-)
would you share which code line raise this exception and what is the code of an error?
DeleteHi ,,
ReplyDeleteit is really a great demo
but i have two blocks , master and detail and at run time it display error message
Frm 41805 ambiguous field ,, the field is the primary key of the master table
<------- ComputerEngineerG: Modyfy this section------->
ReplyDeleteBEGIN
go_block('Block_name');
LC$ITEM := GET_BLOCK_PROPERTY (:system.TRIGGER_BLOCK, FIRST_ITEM);
LC$ITEM := 'Block_name.'||LC$ITEM;
WHILE LC$ITEM IS NOT NULL
LOOP
if LC$ITEM='ROWID' then
LC$ITEM:='Block_name.'||LC$ITEM;
end if;
LC$NAVIGABLE := GET_ITEM_PROPERTY (LC$ITEM, NAVIGABLE);
<------------->
idiots
ReplyDelete