Aftorres02
9/5/2019 - 6:46 PM

select2 . dynamic lov , cascade lov

var selectListShips = {
dropdownAutoWidth: true,
width: '200px',
//minimumInputLength: 1,
ajax: { url: 'wwv_flow.show',
        dataType: 'json',
        quietMillis: 500,
        data: function (term, page) {
            return {
                p_request      : 'APPLICATION_PROCESS=GET_SHIPS_SELECT2',
                p_flow_id      : $v('pFlowId'),
                p_flow_step_id : $v('pFlowStepId'),
                p_instance     : $v('pInstance'),
                x01            : $(this).parent().parent().find('select[name="f03"]').val()
            };
        },
        results: function (data, page) { 
            return { results: data.row };
        },
        cache: true 
    }, // end ajax call
initSelection: function(element, callback) {

  var id = element.val();
        if (id) {
            var data = {id: element.val(), text: shipDic[id]};
            callback(data);
        }
    }, // end init selection 

  placeholder: " ",
allowClear: true};
DECLARE
  l_cursor           sys_refcursor;
	l_param            VARCHAR2 (40)   := apex_application.g_x01; 
	l_row_id           VARCHAR2 (40)   := apex_application.g_x02;  
	l_selected_value	 varchar2 (200);
BEGIN

 
         
  open l_cursor for  select item_shtname "text"
													, item_code "id"
									     from lgms_lov_v
											where upper(lov_code) = 'SHIPS'
												and attribute3 = l_param -- 'PCL'
											order by 1; 
    
  apex_json.open_object;
  apex_json. write('results', l_cursor);
  apex_json.close_object;
END;
declare
l_need_comma boolean := false;
begin
-- Create "dictionary" arrays: 
--   deptDic for Departments
-- They are used for the populating the Select2 items
-- that already have codes and avoid an extra AJAX call for each one.
sys.htp.p('<script>');

sys.htp.prn('var shipDic={');

for d in (
	 select d.item_shtname  as description,
					d.item_code as code
		 from lgms_lov_v d
   	where upper(lov_code) = 'SHIPS'
		order by 1    
)
loop
	if l_need_comma then
		sys.htp.prn(',');
	else
		l_need_comma := true;
	end if;
	sys.htp.prn(d.code || ':"' || replace(d.description, '"','\"') || '"');
end loop;
sys.htp.p('};');

sys.htp.p('</script>');

end;
$('.voyages-lov').select2(selectListVoyages);



  , APEX_ITEM.SELECT_LIST_FROM_QUERY_XL( p_idx  => 6
                                       , p_value => fl.line_tot_type_no
                                       , p_query => q'[SELECT line_tot_type_desc,
                                                              line_tot.line_tot_type_no
                                                         FROM line_total_type line_tot]'
                                       , p_attributes => ' class="c_line_total_type" style="width: 200px;" onchange="change_value_ir(this,'|| seq_id ||',9,''line_tot_type_no'')"'
                                       , p_null_text  => ' '
                                       , p_null_value => null
                                       , p_item_id     => 'line_tot_type_no'||'_'||seq_id
                                                      
       ) line_tot_type
DECLARE
  l_cursor           sys_refcursor;
	l_param            VARCHAR2 (40)   := apex_application.g_x01;  
  l_term             VARCHAR2 (40)   := apex_application.g_x02;  
	l_selected_value	 varchar2 (200);
BEGIN

 
         
  open l_cursor for  select item_shtname || ' '|| item_code "text"
													, item_code "id"
									     from lgms_lov_v
											where upper(lov_code) = 'BRAND'
										    and item_shtname = l_param -- 'PCL'
                        and upper(item_shtname) like '%'|| nvl2(l_term,upper(l_term),upper(item_shtname)) ||'%' 
											order by 1;   
    
  apex_json.open_object;
  apex_json.write('results', l_cursor);
  apex_json.close_object;
END;
select d.* from all_objects d
where rownum <= 10000
/
create table bigtab as
       select d.* from all_objects d
    where -- object_type = 'SYNONYM'
     object_type = 'INDEX'
    or object_type = 'PACKAGE'
    or object_type = 'TYPE'
    or object_type = 'VIEW'
    or object_type = 'TABLE'
    /
select count(d.object_type), object_type
from all_objects d
group by object_type
/

 select object_name "text"
													, object_id "id"
									     from bigtab
											where object_type = 'TABLE'
											--	and attribute3 = l_param -- 'PCL'
											order by 1;