Browsing "Older Posts"

Browsing Category "Interactive Report"

Interactive Report Download Button only for a certain Authorization Role

Von Tobias Arnhold → 4.27.2017
The Interactive Report has this great download feature where you can export everything you can see.
Anyway there are circumstances where the customer doesn't want that feature open for everyone.

In APEX you can only choose if you want the download button or not.
Even so APEX can't do it out of the box. There is a way to make your application able to do it.

Since APEX 5 you can't download when the "Download" is disabled. If you try an almost empty page occurs. Ok that means the "Download" functionality must be activated an I have to disable it manually.

You need to focus on three steps:
 1. Add an authorization scheme.
 2. Hide the download button in the front end. (Visualization)
 3. Disable the download functionality in the back end. (Security)

1. Add an authorization scheme
The authorization scheme will handle the rights that only the correct person is allowed to download from the Interactive Report.
I my case I call it "ROLE_DOWNLOAD" and it works like that:
Type: PL/SQL Function Returning Boolean 
Function Body: return security_pkg.has_role(:APP_USER,'ROLE_DOWNLOAD');
Validate: Once per session

2. Hide the download button
Add a static report id


Add a new "Dynamic Action" on "Click".
jQuery Selector: #STATIC_REPORT_ID_actions_button
Event Scope: Dynamic
Security > Authorization: {Not ROLE_DOWNLOAD}



Add some Javascript to remove the button:
$('#STATIC_REPORT_ID_actions_menu .icon-irr-download').parent().parent().parent().remove();

3. Disable the download functionality
When APEX is exporting something from an "Interactive Report" itjust does a simple redirect on the same page and adds a REQUEST for the specific download type. In my case it is the request "CSV" I want to block.

Add a "Branch" executed "Before Header":


And to disable the download I just redirect on the same page without any request. The trick is to add the right PL/SQL Condition. In this example check for the request and the authorization scheme.

Code:
:REQUEST = 'CSV' and APEX_UTIL.PUBLIC_CHECK_AUTHORIZATION('ROLE_DOWNLOAD') = false

 
In my mind this is simple and secure and shows how flexible APEX really is.

Customize your Interactive Report with CSS

Von Tobias Arnhold → 3.28.2017
A lot of you are using jQuery to customize visual parts of an APEX application. I probably to often do so myself but there is a much more elegant way:   CSS

Nowadays you are able to add different kind of rules into your CSS styles. In this example I will show you how to get into the topic by changing an Interactive Report (IR). In my example I want to change the typical group by visualization.


Before


After


First of all you need to give your IR a unique name or class to identify it properly.
IR > Appearance > CSS Classes: irCustomStyles



Now you need to add the customized CSS code in your page:
Page > CSS > Inline

.irCustomStyles .a-IRR-table td {
    border-top: 0 solid #ffffff !important;
}

.irCustomStyles table.a-IRR-table th:first-child.a-IRR-header:not(.a-IRR-header--group) {
  background-color: white !important;
}

.irCustomStyles table.a-IRR-table tr:has( .a-IRR-header ) {
    border-bottom: medium none white !important;
    border-top: medium none white !important;
}

1. Rule: Takes the border from the TD elements away. Standard CSS probably most of you have done like this before. 
2. Rule: This one changes only the first TH element and when they are not referenced with class ".a-IRR-header--group"
3. Rule: The "has"-clause only applies if the result is true. In this case if a class called "a-IRR-header" exists.

Fore more details check those sources:
:not(s) - By Sara Cope
Selecting Parent Elements with CSS and jQuery - by Thoriq Firdaus

Interactive Report with a Font Awesome edit icon

Von Tobias Arnhold → 7.01.2016
Most of you know the default APEX edit icons you can choose from inside your Interactive Report.
Basically you use them to link to a detail page.


The icon source looks like this.


A typical result page.


Two things I would like to change:
 1. The Icon should be a nice looking car symbol from the Font Awesome library.
 2. The column width should be as small as the icon and not relative to the page width.

We change the pencil.png towards the nice looking automobile icon from Font Awesome.
Code:  
<span class="fa fa-automobile"></span> 
 

Then we add a little CSS snippet to the page inline CSS.
Code:
.minimize-first-table-col td:first-child{
  width: 1%;
  overflow: visible;
  font-size:120%;
  padding: 8px;
}



And as a last step we add the class minimize-first-table-col inside the Interactive Report > Appearance > CSS Classes.


The result will looks like this.


Reset Interactive Report (IR)

Von Tobias Arnhold → 6.30.2016
Resetting an Interactive Report (IR) can be done in 4 different ways.
User Reset, URL Link, Page Process, Dynamic Action

First of all
It is always a good start to set up a specific static report id.


1.  User Reset
Not much to say.


1. URL Link

f?p=&APP_ID.:1:&APP_SESSION.:::RIR,CIR:

Cache definition:
- RIR: reset IR to primary report
- CIR: reset IR to primary report but with custom columns
- RP: reset IR pagination.

More details about the difference of RIR and CIR can be found here:
Apex Interactive Report: The difference between CIR and RIR

Basically all you need to know about the URL options in an IR can be found in the documentation:
Application Express Application Builder User's Guide


Also be aware that you can use several IR since APEX 5 on one page. Filters must now be applied in a specific syntax:
IR[region static ID]_

2. Page Process (Before Header)
DECLARE
  v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN

  SELECT region_id INTO v_region_id
  FROM APEX_APPLICATION_PAGE_REGIONS
  WHERE application_id = :APP_ID
  AND page_id = 1
  AND static_id = 'IR_RO_REPORT_ID'; -- Static ID of your IR

  APEX_IR.RESET_REPORT(
   P_page_id => 1,
   P_region_id => v_region_id,
   P_report_id => NULL
  );

END;

3. Dynamic Action
Create a new Dynamic Action.
Add a TRUE action of type "Execute PL/SQL code"  and use the same code as above.
And finally add another TRUE action to refresh the IR.

If you still need more information then take a look here:
Reset an Interactive Report (IR)

APEX Master (Interactive Report) - Detail (Modal Dialog) Form: Conditional Column Link

Von Tobias Arnhold → 6.15.2016

Since APEX 5 it is much easier to create master-detail pages with modal dialogs. But there is still no declarative way to create a conditional row based column link.

This blog post will show you a way how to create a conditional row based master - detail page.

1. We need some sample data:
WITH MY_DATA AS
(
select 1 as ID, 'APEX Connect' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 2 as ID, 'KScope' as name, 0 as CONDITIONAL_COL from DUAL
union all
select 3 as ID, 'DOAG' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 4 as ID, 'APEX-FRA Meetup Group' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 5 as ID, 'Oracle World' as name, 0 as CONDITIONAL_COL from DUAL
)
select 
  ID,
  NAME,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'inline-block'
  else 'none' end as CSS,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'Visited conference'
  else 'Not visited yet' end as DETAIL_COL
from MY_DATA
As you can see the column CONDITIONAL_COL defines the conditional appearance.
CONDITIONAL_COL = 1 means show a detail button.
CONDITIONAL_COL = 0 means no detail button.

2. Now we can create a APEX master detail page where the "Page Mode" of the detail page is set to:
"Modal Dialog".


The master page gets an Interactive Report with the above select statement.

3. Now we need to configure the column attributes inside the Interactive Report:
Columns ID and NAME with be displayed as of type: "Plain Text".
Column CSS will not be displayed: "Hidden Column"
Column DETAIL_COL will be displayed as of type: "Link"
 - Target: 
   - Page: 2
   - Set Items: P2_ID - #ID#
 - Link Text: <span class="fa fa-search-plus" style="font-size: 160%"></span>
 - Link Attribues: class="a-Button" style="display:#CSS#;"
 We created a custom link for our detail page.


And the functionality to display the detail button conditionally is set by the column "CSS".


The result looks like this:

You can even filter the button by some readable data:


Security issue:
On the detail page you need a validation to check if the user is allowed to edit the data of the transmitted ID. An alternative way is to update the select so that no ID value will be generated if the user has no rights.
Example:
WITH MY_DATA AS
select 
  case when nvl(CONDITIONAL_COL,99) = 1 then
       ID
  else NULL end as ID,
  ID as ID_DISPLAY
  NAME,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'inline-block'
  else 'none' end as CSS,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'Visited conference'
  else 'Not visited yet' end as DETAIL_COL
from MY_DATA
APEX-AT-WORK no image

Veranstaltungs-News

Von Tobias Arnhold → 9.17.2014
Am 26. September ist das erste APEX Meetup Treffen in Frankfurt:
http://www.meetup.com/orclapex-fra/events/207768912/

Am 05. November halte ich einen Vortrag zum Thema Plugins und Reporting in Bonn:
http://www.orbit.de/unternehmen/service/veranstaltungen/#c1398
Weitere Vorträge werden von Denes Kubicek & Frank Weyher gehalten.

DOAG 2014 im November:
http://www.doag.org/events/konferenzen/doag-2014.html
http://www.apex-at-work.com/2014/09/doag-2014-vortrag-zum-thema-dynamisches.html
 
-------------------------------------------------------------------------------------------------------------

Ich sah gerade noch einen Blogpost zum Thema "Warum ist APEX so GEIL!?".
Ok der Titel war etwas besser formuliert :)
http://www.explorer-development.uk.com/7-things-about-apex-your-boss-needs-to-know/

APEX Interactive Report mit der Save Public Report Option

Von Tobias Arnhold → 2.18.2012
Wenn Sie ihren Endnutzern die Möglichkeit geben einen Interactive Report als Public Report abzuspeichern, dann ist dies automatisch für alle Nutzer möglich. Im Normalfall dürfen nur einzelne Power-Nutzer diese "Öffentlichen Reports" erstellen.
Die Option: Save Public Report Authorization gibt Ihnen die Möglichkeit über ein Authorization Schema den Power-Nutzer zu definieren.

 
Weitere Informationen finden Sie auch in der APEX Dokumentation:
Optionally select an authorization scheme. This authorization scheme must evaluate to TRUE to save Public Report. If no authorization scheme is provided then reports may be saved by anyone.
--------
Users can save reports and classify them as being either public or private. Public reports can be viewed by all users. Private reports can only be viewed by the user who saved the report.
In addition to enabling Save Public Report under Actions Menu, you can add additional security by defining an Authorization Scheme to determine who has rights to enable Save Public Report.
To enable support for public reports, select an authentication method from this list.


IR Extender

Von Tobias Arnhold → 2.13.2012
I'm working on a new plug-in called IR Extender. With this plug-in you will get more control about your Interactive Report.

- Default Filter Handling
Should your customized IR show all filters even if they are default?
I added a blog about this topic before: http://www.apex-at-work.com/2011/08/irr-remove-single-rule.html  The described solutions will be part of the plug-in.


- Action Menu Extension
Based on the great idea from Jarola I'm currently working on a more advanced way adding individual entries and sub menu's to your Interactive Report. All will be controlled by the plug-in.

At the moment I have a preview image which gives you a hint about what will come:

I added to more entries inside the main control
One is a simple entry with some javascript action and the other one is a sub menu entry inlcuding a sub menu with two extra entries.

Tobias

Update 14.02.2012
I created a first version of the "Action Menu Extension":
http://apex.oracle.com/pls/apex/f?p=65560:20

Update 18.02.2012
I will add two more functionalities to the plug-in.
 - Custom delete of an entry
 - Move of an entry to another position
 - IR fix which is useful in customized layouts like ExtJS and so on

I just saw a similar plug-in published on http://www.apex-plugin.com/ which seems to use a similar technology as I do. It is also based on the extension from Jarola: https://forums.oracle.com/forums/thread.jspa?threadID=2344657&tstart=30
Even so that there is a plug-in similar to mine I still will go on with the development.
APEX-AT-WORK no image

IRR: UILayout issue

Von Tobias Arnhold → 8.17.2011
If you use the UILayout plug-in for APEX with Interactive Reports you will see some issues inside the action menu. The "Rows Per Page" and the "Format" menu will be positioned above the main action menu.

To fix this use the following js snippet with a dynamic action or add it inside your page header:
$('.dhtmlSubMenuS').mouseover(function() {

  $('#apexir_ROWS_PER_PAGE_MENU').css({

    left: $('#apexir_ROWS_PER_PAGE_MENU').position().left + 200 + "px"

  });

  $('#apexir_FORMAT_MENU').css({

    left: $('#apexir_FORMAT_MENU').position().left + 200 + "px"

  });    

});


Create a Dynamic Action which fires on the refresh of your Interactive Report and executes the JS code. Run it also on page load.

I will fix it in one of the next versions of the plug-in.

IRR: Remove single rule

Von Tobias Arnhold → 8.09.2011
If you want to remove easily a single rule inside your interactive report then use this javascript code snippet:

$('a:contains(Vorname ist Null)').parent().parent().remove();

Customized IRR example:
/* Remove Highlight rules */

$('a:contains(MY_RULE1_BLUE)').parent().parent().remove();

$('a:contains(MY_RULE2_GREEN)').parent().parent().remove();

$('a:contains(MY_RULE3_ORANGE)').parent().parent().remove();

/* remove filter */

$('a:contains(My Column filter = \'FILTER\' )').parent().parent().remove();

/* Remove named report */

$('a:contains(Gespeicherter Bericht = \"My filtered report\")').parent().parent().remove();

/* Remove group label text */

$('#apexir_SAVED_REPORTS optgroup[label="Standard"]').attr("label","");

$('#apexir_SAVED_REPORTS optgroup[label="Öffentlich"]').attr("label","");

/* Remove Control Panel Control and make it always active */

$('#apexir_CONTROLS_IMAGE').removeClass('pseudoButtonActive');

$('#apexir_CONTROLS_IMAGE').addClass('pseudoButtonInactive');

/* gReport.toggle_controls($x('apexir_CONTROL_PANEL_CONTROL')); */

$('#apexir_CONTROL_PANEL_CONTROL').hide();
APEX-AT-WORK no image

IRR: Get current report selection

Von Tobias Arnhold → 8.06.2011
With Interactive Reports you are able to save several views of one report source.
- Default
- Public
- Private

Your end user can easily choose from those saved reports.
If you need to know which the currently viewed report is then you can use this little js code snippet:
alert(
'ID: ' + 
$('#apexir_SAVED_REPORTS').val() + 
', Text: ' + 
$('#apexir_SAVED_REPORTS :selected').text()
);


Try it inside a dynamic action!

Interactive Report Header problem with multiple lines

Von Tobias Arnhold → 2.28.2011
There is a bug/misbehavior inside the IRR column headers in APEX 4. When you create column names with linebreaks (using the <br> tag) inside then the background color changes to a grey background on the second line.
Workaround: Add this script to your IR region header:
<style>
/* IRR Header Fix */
.apexir_WORKSHEET_DATA th{background-color:#828282!important;}
</style>


Bug view:

Fixed view:


There is a forum entry as well: http://forums.oracle.com/forums/thread.jspa?threadID=1981024

Building IR filters with AJAX - not solved yet

Von Tobias Arnhold → 3.17.2010
I got stuck on a problem with Interactive Reports.
I wanted to build filters during the application runtime with AJAX. These filters should be created if an user makes changes with select lists or trees similar to my old example:
IR with dynamic rules

What I need now are exact filters on hidden or visible fields:


My idea was to use the apex_util.ir_filter procedure:
apex_util.ir_filter(
p_page_id in number, -- Page that contains an Interactive Report
p_report_column in varchar2, -- Name of the report SQL column to be filtered
p_operator_abbr in varchar2 default null, -- Filter type
p_filter_value in varchar2); -- Value of filter, not used for N and NN

With an application process:
-- application process AP_GET_CAT
declare
  V_CAT varchar2(100);
begin
 select c.cat_name into V_CAT from categories where c_id = :P1_C_ID;

 apex_util.ir_filter(
  p_page_id=>1,
  p_report_column=>'CAT_NAME',
  p_operator_abbr=>'EQ',
  p_filter_value=>V_CAT);

 htp.prn(V_CAT);
end;

and some javascript:
// js get cat data
function set_cat(v_id) {
  var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=AP_GET_CAT',0);
  get.add('P1_C_ID',v_id)
  $x('P1_C_ID').value = v_id;
  gReturn = get.get();
  get = null; 
}

The functionality itself worked well but a submit is required for the APEX procedure apex_util.ir_filter.

My other idea was to imitate the user actions with javascript only:
// js code: set IR filter
$x('apexir_COLUMN_NAME').value = 'CAT_NAME';
$x('apexir_STRING_OPT').value = '=';
$x('apexir_EXPR').value = $x('P1_CAT_NAME').value;
gReport.column.filter();

Unfortunately it doesn't work this way... But it feels close to a solution.

It works if I use a sql where clause for my IR like this:
SELECT s_id, sales, sales_info
FROM sales, categories
WHERE s_c_id = c_id
AND s_c_id = :P1_C_ID;

and some javascript:
// not tested
var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=AP_GET_CAT',0);
get.add('P1_C_ID',v_id)
$x('P1_C_ID').value = v_id;
gReturn = get.get();
init_gReport();gReport.reset();gReport.pull();
get = null; 

Maybe one of you guys did already solve this task and could help me out here.

Forum entry: http://forums.oracle.com/forums/thread.jspa?messageID=4167521

Tobias