Menu

Adding dynamic lookups (LOV's) - select elements - JSON

2018-07-12
2018-09-14
  • Domen Dolar

    Domen Dolar - 2018-07-12

    To add dynamic LOV you should:

    1: Create master LOV in Links-LOV section. Name lov$lov_job

    Sample:

    select '' id , '' label from dual union
    SELECT 
     JOB ID
    ,DESCRIPTION||'['||JOB||']' LABEL
    FROM JOBS 
    ORDER BY 1
    

    2: Create detail LOV in Links-LOV section. Name lov$LOV_EMP

    Sample:

    select to_number(null)  id , '' label from dual union
    SELECT 
     EMPNO ID
    ,ENAME||'['||EMPNO||']' LABEL
    FROM EMP 
    WHERE 
      JOB = FCJOB
    ORDER BY 1
    
    1. Put field FCJOB on the Form level (Fields on block section). It is not neccesary that field US is checked.
    2. Create master field on block. Sample field CJOB on block B10 Type=Input select LOV and LOV/Link= lov$lov_job
    3. Create target field on block. Sample field CEMP on block B10 Type=Input select LOV and LOV/Link= lov$LOV_EMP
    4. Connect LOV's in javascript (section CSS,JS source -> FORM-JS)
    $(document).ready(function() {
    
    //Inicialization
       $('select[name^="B10CJOB"]').each(function() {
          addDynamicLOV('lov$LOV_EMP', 'FCJOB',  this , '#each_val#', 'B10CEMP' );
       });   
    
    //Trigges on change
       $('select[name^="B10CJOB"]').change(function() {
          addDynamicLOV('lov$LOV_EMP', 'FCJOB',  this , this.value, 'B10CEMP' );
       });
    
    } );
    
     

    Last edit: Domen Dolar 2018-07-12
  • Anonymous

    Anonymous - 2018-09-14

    If you use more than one parameter in LOV. Then you put all filter fileds on Form level. So the SQL would be: select id, label from xxx where name = FCOND1 and title = FCOND2

    IN JS this will look like:

    //Inicialization 
       $('select[name^="B10SELECTLIST"]').each(function() {
    
         var lovobject = document.createElement('input');
         lovobject.value = 
         '&FCOND1='+    document.getElementById('B10SELECTLIST'+'_'+this.name.substring(this.name.lastIndexOf("_")+1)+'_RASD').value +
         +'&FCOND2=' +
    document.getElementById('B10OTHERFILAD'+'_'+this.name.substring(this.name.lastIndexOf("_")+1)+'_RASD').value 
    ;
    
         lovobject.name = this.name;
    
          addDynamicLOV('lov$name', '',  lovobject , '#each_val#', 'B10SELECTLISTTARGET' );
    
       });   
    
      //Trigges on change
       $('select[name^="B10SELECTLIST"]').change(function() {
          addDynamicLOV('lov$name', '',  this , 
         '&FCOND1='+    document.getElementById('B10SELECTLIST'+'_'+this.name.substring(this.name.lastIndexOf("_")+1)+'_RASD').value +
         +'&FCOND2=' +
    document.getElementById('B10OTHERFILAD'+'_'+this.name.substring(this.name.lastIndexOf("_")+1)+'_RASD').value 
          , 'B10SELECTLISTTARGET' );
       });
    
     

    Last edit: Domen Dolar 2018-09-14

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.