Wednesday, May 13, 2015

Dependent Drop Down List


In the name of Allah, Most Gracious, Most Merciful
Praise be to Allah, blessing and peace be upon our prophet Mohammed, his family and his companions. After that,

Key Problem:
 The problem you will face when you have two popup lists and you are attempting to populate the second  popup list depending on the selected  value of 
the first popup list is



Key Solution: 

Let's Suppose we have the first list DNAME which displays all the department names stored in the department table.
The idea of populating the second popup list depending on the selected value of the first popup list is replies in using a specific DEPTNO value to filter the values displayed according to the Second popup list


The following example is intended to populate  the emp_name in respect to the first list-item selection of e.g. DNAME 


In When-List-Changed  Trigger of the First List e.g." DNAME"  you have to write the 

following code...




 
-- The following code attain the key solution of the problem.
-- The list DNAME will be changed depending on the DNAME list value  
-- selection & filtered by the DEPTNO
 
DECLARE
 
rg_city RECORDGROUP;
rg_name VARCHAR2(40) := 'EMP';
list_id Item := Find_Item('EMP.ENAME');
vTemp NUMBER;
 
BEGIN

-- The following is checking your Group doesn't already exist through 
-- searching for it and delete it if exists.
 
rg_city  := FIND_GROUP(rg_name); 
IF NOT id_null(rg_city) 
 THEN Delete_Group(rg_name);
End if;
  
-- If it doesn't exist then create it and add your query to it
 
rg_city :=CREATE_GROUP_FROM_QUERY(rg_name , 'SELECT ENAME , ENAME FROM EMP WHERE EMP.DEPTNO = '|| :DEPT.DEPTNO);
 
SET_RECORD_PROPERTY(:system.cursor_record,'EMP',status,new_status);
vTemp:=POPULATE_GROUP(rg_name);
 POPULATE_LIST('EMP.ENAME', rg_name); 
 
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
WHEN OTHERS THEN MESSAGE('Follow up the error : '||SQLERRM); 
END;


Note: in the select statement there are two database columns selected; 'SELECT ENAME , ENAME' one column for the 'List Element' and the other column is  for 'List Item Value'. In compare with 'The Static List Item' that has a fixed value; "Elements In List" property.


 Three Steps to Forms Data Exchange "Parameter List":   Learn More about




My success only comes from Allah, pls. note your comments and suggestions are great 

help for me in progress thanks in advance.