Highlighting Selected Records in Oracle Forms


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 below
     NAME: 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 SELECTED
change 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

Popular posts from this blog

ADF : Get Current Logged User Name

OAF : Get Current Row in Table

ADF : Working with ViewCriteria