#44 Dynamic link tabs in Oracle APEX

Hi all,

For my own application, I have build a page with hero and a tab region. The tabs(2) shows a classic report with data. In the hero region I placed a button. So I was wondering how to create a dyncamic link. For example:
  • When tab A is active, the button must open modal A.
  • When tab B is active, the button must open modal B.

Steps:

  1. Create a dynamic action 
  2. Create action; Execute Javascript code 
  3. Create a AJAX Callback process 

Explanation:

  1. Create a dynamic action 
    Choose a click event and choose the button as selector.
  2. Create action; Execute Javascript code
    The Javascript code will look wich tab is active and open the modal with the apex.navigation API
  3. var isActive = $(".a-Tabs-panel.a-Tabs-element-selected").attr("data-label");
    
      if (isActive === 'TAB A')
      {      
         apex.server.process ( "URL", {
             x01: 'A'
         }, {
         success: function(Data) 
             { 
               apex.navigation.redirect(Data);
             }
         });
      }
      else
      {
         apex.server.process ( "URL", {
             x01: 'B'
         }, {
         success: function(Data) 
             { 
               apex.navigation.redirect(Data);         
             }
         });
      };
  4. Create a AJAX callback process
    This process creates the dynamic links and puts it into a JSON array.
  5. declare
      l_url    varchar2(500);
    
    begin
      if apex_application.g_x01 = 'A'
      then
        l_url := apex_util.prepare_url(p_url           => 'f?p='||v('APP_ID')||':3:'||v('APP_SESSION')||'::NO:3'
                                      ,p_checksum_type => 'SESSION');
      else
        l_url := apex_util.prepare_url(p_url           => 'f?p='||v('APP_ID')||':4:'||v('APP_SESSION')||'::NO:4'
                                      ,p_checksum_type => 'SESSION’):
      end if; 
    
      apex_json.open_array;
      apex_json.write(l_url);
      apex_json.close_array
    end;
     

See you next time!

Comments

Popular posts from this blog

#19 Clear cache in a PL/SQL process in Oracle APEX

#38 Oracle apex static height region

#43 Add color to selected tab Oracle APEX