Archive

Archive for June, 2007

ApEx: Conditionally display “Export to Excel/CSV” Link

June 24, 2007 1 comment

From within Report Attributes for a report it is possible to turn on “Enable CSV Output” which causes a link to be displayed below the report which, when clicked, downloads a .CSV representation of the data in the report. Very useful. However, this turns on the “Export to CSV” link for all users. What if you want to make this link available to only a subset of your users?

To achieve this you can do the following:

1) Add a hidden item to the page that contains your report. Call it something like PX_CSV_LINK_TEXT where x should be replaced with the page number.

2) Under Report Attributes for your report, under the “Report Export” options, set “Link Label” to:

&PX_CSV_LINK_TEXT.

3) Add an “On Load – Before Header” Page Process of type PL/SQL setting its source to something like the following:

IF APEX_UTIL.current_user_in_group('ADMIN') THEN
:PX_CSV_LINK_TEXT := 'Export to .CSV';
ELSE
:PX_CSV_LINK_TEXT := NULL;
END IF;

Change the logic in step 3 to fit your particular requirements. The example above will display the “Export to .CSV” link only if the user is a member of the ADMIN user group.

Categories: ApEx

ApEx: Using Scrollbars in a Region

June 14, 2007 10 comments

ScrollbarsIf you’ve got a report with a lot of rows to display you’ve standardly got a couple of options:

1) Paginate

2) Show all the rows and let the user scroll down the page.

Here’s a third option: Get the region which contains the report itself to scroll. You can see a demo here:

http://apex.oracle.com/pls/otn/f?p=666666:10

This is achieved by setting the Region Header to:

<div style="overflow: auto; height: 450px;">

And the Region footer to:

</div>

Just change the value of 450px as desired and that’s it.

Note: One problem with this is that if the rows of your report don’t fill the full 450 pixels then you end up with white space at the end of the report. You can use max-height instead of height to get round this problem. Unfortunately, however, max-height does not seem to work with Internet Explorer (6.0 or 7.0) but does work with Firefox. Since the production environments where Firefox can be guaranteed to be the sole browser used are few and far between, the upshot is that we are generally forced to use height as opposed to max-height.


Acknowledgments: Thanks to Brian Barenbaum for coming up with the idea of using “max-height” instead of just “height” in the DIV’s style tag (See comment 5 of this blog entry).

Categories: ApEx

Rendur.com: Speedy HTML Preview

rendur logo

This tool isn’t related to ApEx specifically but I’ve found it to be useful from time to time. Essentially, it gives you a large, resizable text area into which you can type HTML and CSS which it renders on the page as you type. Nothing hugely complex but for hacking about at the odd bit of HTML it’s certainly quicker than firing up a text editor, saving your file and previewing it in a browser.

Find it at:

http://www.rendur.com/

Categories: CSS, HTML

Automatically converting text to uppercase

June 12, 2007 4 comments

ABCSometimes you want to force users to enter text into one of your ApEx page items in upper case. You can achieve this quite easily by adding the following bit of code to the HTML Form Element Attributes of your item:

onChange="this.value=this.value.toUpperCase();"

Or, if you want to force the text to lower case:

onChange="this.value=this.value.toLowerCase();"

Categories: ApEx, Javascript