I have just discovered (thanks to a tweet by @jeffreykemp) that in APEX 5.0 there is now a function called APEX_PAGE.GET_URL:
About time! I've been using this home-made version for years:
So if I want to create a URL that redirects back to the same page with a request I can just write:
return my_apex_utils.fp (p_request=>'MYREQUEST');
One difference is that the one I use has a parameter to decide whether or not to "prepare" the URL (add the checksum etc.) This has been needed sometimes to ensure a URL is not prepared by the function because APEX goes ahead and prepares it again resulting in an invalid URL with two checksums. If I recall correctly this can happen when the URL is used in a branch. Perhaps this doesn't happen in APEX 5.0 though?
Some very occasional musings on matters concerning Oracle specifically or databases in general.
Friday, May 27, 2016
Monday, May 16, 2016
APEX plugin: make tabular report responsive
I often have to build APEX applications that are responsive to the size of the screen they are running on - from desktops down to mobile phones. While this can be achieved quite easily using a modern responsive theme, reports are often a problem. For example, this report looks fine on a desktop:
... but gets truncated on a mobile:
Here I'm using the APEX 5.0 Universal Theme, which at least adds a horizontal scrollbar to the report, but that isn't always ideal.
I came across a solution that I liked here which uses CSS alone to reformat the report vertically on small screens - like this:
Try my demo page at http://tiny.cc/apexrr (e.g. try it on your phone).
I won't go into the details of how it works as the blog post I referenced above does that already. However, a big attraction for me was that it does not require any Javascript, because I often have to build public website applications that need to work with Javascript disabled (yes, I know!)
Having used this technique a couple of times I decided it would be worth wrapping up into a plug-in. After some deliberation I decided to make it a dynamic action plug-in, so that it can be added to apply the styling to a specified report region without having to manually add any CSS to the page. However, it is an unusual dynamic action because it doesn't actually do anything dynamic - the Javscript function it performs is a dummy that does nothing. The useful work is done by CSS that the plug-in adds to the page while rendering.
There are 3 settings for this plug-in - 2 at application level and 1 at component level:
... but gets truncated on a mobile:
Here I'm using the APEX 5.0 Universal Theme, which at least adds a horizontal scrollbar to the report, but that isn't always ideal.
I came across a solution that I liked here which uses CSS alone to reformat the report vertically on small screens - like this:
Try my demo page at http://tiny.cc/apexrr (e.g. try it on your phone).
I won't go into the details of how it works as the blog post I referenced above does that already. However, a big attraction for me was that it does not require any Javascript, because I often have to build public website applications that need to work with Javascript disabled (yes, I know!)
Having used this technique a couple of times I decided it would be worth wrapping up into a plug-in. After some deliberation I decided to make it a dynamic action plug-in, so that it can be added to apply the styling to a specified report region without having to manually add any CSS to the page. However, it is an unusual dynamic action because it doesn't actually do anything dynamic - the Javscript function it performs is a dummy that does nothing. The useful work is done by CSS that the plug-in adds to the page while rendering.
There are 3 settings for this plug-in - 2 at application level and 1 at component level:
- Application setting 1: CSS class of the report's container. This is normally a div that surrounds the whole report, which will have its width set to 100% on small screens by the plug-in.
- Application setting 2: CSS class of report data table. This is the table that contains just the report data (not the pagination etc.), which will be transformed by the plug-in.
- Component setting 1: Max screen width (px) affected This governs when the transformation kicks in - default is 760 (pixels).
My thinking (currently) is that the classes will be the same from region to region within the same applicaiton, as they come from the report template, whereas the screen width at which the report needs to be transformed could vary from one region to another.
When installing the plug-in you need to set the 2 application settings for the CSS classes appropriately for the report templates you are using.
To use the plug-in you need to create a dynamic action for each report region to which it needs to be applied as follows:
- Event: Page load
- Condition: none
- Action: this plug-in
- Max screen width (px) affected: as you wish (or leave as default)
- Selection type: Region
- Region: the region to apply it to
There are some limitations and caveats to be aware of:
- It only works on classic reports, not interactive reports. I'm not really sure it would make sense on IRs, and their HTML is different to that of classic reports.
- Column header sorting functionality is lost when the report is transformed for the small screen,
- The report headings must be enclosed in a element - you may need to edit your report template and add this (in the before/after column heading sections).
- The data table must have a class (to use in the component settings) - again, the report template can be edited if necessary.
If anyone cares to try it out and can give any feedback on how this could be improved I'd be glad to receive it - it will be available on apex-plugin.com very soon.
Subscribe to:
Posts (Atom)