Skip to main content

Formatting a Download Link

Providing file upload and download capabilities has been native functionality in APEX for a couple major releases now. In 5.0, it's even more streamlined and 100% declarative.
In the interest of saving screen real estate, I wanted to represent the download link in an IR with an icon - specifically fa-download. This is a simple task to achieve - edit the column and set the Download Text to this:
<i class="fa fa-lg fa-download"></i>
The fa-lg will make the icon a bit larger, and is not required. Now, instead of a "download" link, you'll see the icon rendered in each row. Clicking on the icon will download the corresponding file. However, when you hover over the icon, instead of getting the standard text, it displays this:
2016 01 13 16 28 16
Clearly not optimal, and very uninformative. Let's fix this with a quick Dynamic Action. I placed mine on the global page, as this application has several places where it can download files. You can do the same or simply put on the page that needs it.
The Dynamic Action will fire on Page Load, and has one true action - a small JavaScript snippet:
$(".fa-download").prop('title','Download File');
This will find any instance of fa-download and replace the title with the text "Download File":
2016 01 13 16 28 43
If you're using a different icon for your download, or want it to say something different, then be sure to alter the code accordingly.

Comments

Mathieu said…
Hello Scott,

It is even nicer if you make your tooltip text translatable.
You have to create an APEX text message (don't forget "use in javascript" = Yes) for the languages needed.

Change the dynamic action like this:
var gTitle = apex.lang.getMessage("DOWNLOAD_FILE_TEXT");
$(".fa-download").prop('title',gTitle);

Regards,

Mathieu

Popular posts from this blog

Universal Theme Face Lift

I'm a huge fan of APEX's new Universal Theme, and have been working quite a bit with it.  One of the coolest features is how easy it is to change the colors.  You don't even need to be good at design - just click Theme Roller, and spin all the things! However, as much as you change the colors, the look and feel still largely looks the same, since the base font is unchanged. So let's change it up! More importantly, let's change it up without making any changes to the Universal Theme itself, so that when we upgrade to APEX 5.1, our changes will be preserved. First, head on over to Google Fonts ( https://www.google.com/fonts ) and pick a font to use as your new base font.  It doesn't really matter which one you use.  For this example, I’m going to use Montserrat.  Once you've chosen which font to use, click on the Quick Use icon.  This will render a page with a number of different options as to how to include the font in your application. Select which st

Drop It Like It's Not

I just ran the following script: -- TABLES FOR x IN (SELECT table_name FROM user_tables) LOOP   EXECUTE IMMEDIATE('DROP TABLE ' || x.table_name || ' CASCADE CONSTRAINTS'); END LOOP; -- SEQUENCES FOR x IN (SELECT sequence_name FROM user_sequences) LOOP   EXECUTE IMMEDIATE ('DROP SEQUENCE ' || x.sequence_name); END LOOP; -- VIEWS FOR x IN (SELECT view_name FROM user_views) LOOP   EXECUTE IMMEDIATE ('DROP VIEW ' || x.view_name); END LOOP; Basically, drop all tables, views and sequences.  It worked great, cleaning out those objects in my schema without touching any packages, producers or functions.  The was just one problem:  I ran it in the wrong schema. Maybe I didn't have enough coffee, or maybe I just wasn't paying attention, but I essentially wiped out a schema that I really would rather not have.  But I didn't even flinch, and here's why. All tables & views were safely stored in my data model.  All sequence