Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Plugin pivot table with different js files - help for the PL/SQL Code

LoupigMar 8 2016 — edited Mar 8 2016

Hi everyone,

This is my very first post in this very helpull comunity, I hope to fine my answers thanks to the mix of all your knowledges!

There is my problematic: Apex 4.2.1.00.08 and / or Apex 5.0.2.00.07

I have downloaded a PivotTable  PlugIn in my application. It works really well, you should try it !. (Note there is already a post about the modifications to get it worked in Apex5  )

On GitHub I found several additionnal renderer and i would love to add these to my PivotTable. You can find severals exemple and even try it with your ouwn data here, and severals docuentations here

My question is simple, because I'm a straight beginner in this field, how to do it? I tried to get closed to the original PL/SQL Code but I can't got it.. I could add some parameters but not add the "add-ons" renderer files..

Thes SQL Code:

function render_pivot (p_region in apex_plugin.t_region,

                       p_plugin in apex_plugin.t_plugin,

                       p_is_printer_friendly in boolean ) return apex_plugin.t_region_render_result

as

  l_returnvalue                  apex_plugin.t_region_render_result;

  l_element_name                 varchar2(2000) := p_region.attribute_01;

  l_columns                      varchar2(2000) := replace(upper(p_region.attribute_02), ',', '","');

  l_rows                         varchar2(2000) := replace(upper(p_region.attribute_03), ',', '","');

  l_renderer                     varchar2(2000) := p_region.attribute_04;

  l_enable_ui                    varchar2(2000) := p_region.attribute_05;

  l_aggregatorName               varchar2(2000) := p_region.attribute_06;

  l_vals                         varchar2(2000) := p_region.attribute_07;

  l_ajax_id                      varchar(2000) := apex_plugin.get_ajax_identifier;

  l_data_name                    varchar2(2000) := 'pivot_data_' || l_ajax_id;

  l_options_name                 varchar2(2000) := 'pivot_options_' || l_ajax_id;

  l_onload_code                  varchar2(32000);

begin

  apex_css.add_file (

    p_name => 'pivot.min',

    p_directory => p_plugin.file_prefix);

  apex_css.add_file (

    p_name => 'c3.min',

    p_directory => p_plugin.file_prefix);

  -- note: this file is also found in /i/libraries/jquery-ui/1.8.22/ui/minified/ but is not included by default by Apex

--  APEX 5.0 has a more recent version of the library at /i/libraries/jquery-ui/1.10.4/ui/minified/jquery.ui.sortable.min.js, and the plug-in works when used with this.

  apex_javascript.add_library (

    p_name      => 'jquery.ui.sortable.min',

    p_directory => p_plugin.file_prefix);

  apex_javascript.add_library (

    p_name      => 'pivot.min',

    p_directory => p_plugin.file_prefix);

/* apex_javascript.add_library (

    p_name      => 'd3.min',

    p_directory => p_plugin.file_prefix);

  apex_javascript.add_library (

    p_name      => 'c3.min',

    p_directory => p_plugin.file_prefix);

  apex_javascript.add_library (

    p_name      => 'c3_renderers.min',

    p_directory => p_plugin.file_prefix); 

  apex_javascript.add_library (

    p_name      => 'jquery-ui.min',

    p_directory => p_plugin.file_prefix);

  apex_javascript.add_library (

    p_name      => 'jquery.ui.touch-punch.min',

    p_directory => p_plugin.file_prefix);            */

  htp.p('<div id="' || l_element_name || '">Loading, please wait...</div>');

  htp.p('<script>');

  htp.p('var ' || l_data_name || ' = ');

  apex_util.json_from_sql (p_region.source);

  htp.p(';');

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

  if l_enable_ui = 'Y' then

    l_onload_code := 'var ' || l_options_name || ' = {cols: ["' || l_columns || '"], rows: ["' || l_rows || '"], vals: ["' || l_vals || '"], aggregatorName: "' || l_aggregatorName || '", rendererName: "' || l_renderer || '"};';

    l_onload_code := l_onload_code || '$("#' || l_element_name || '").pivotUI(' || l_data_name || '.row, ' || l_options_name || ');';

  else

    l_onload_code := 'var ' || l_options_name || ' = {cols: ["' || l_columns || '"], rows: ["' || l_rows || '"]};';

    l_onload_code := l_onload_code || '$("#' || l_element_name || '").pivot(' || l_data_name || '.row, ' || l_options_name || ');';

  end if;

  apex_javascript.add_onload_code (l_onload_code);

  return l_returnvalue;

end render_pivot;

Thank you in advance for your answers and your help.

Best

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2016
Added on Mar 8 2016
0 comments
592 views