Video: Part 4 – Implementing Drag & Drop functionality


Do you want to add Drag & Drop functionality to your APEX applications?
That’s what this video is all about.

You’ll see me working on the list created in the previous episodes (Part 1, Part 2 and Part 3) and add the necessary JS to implement.

During the video, I follow this companion blog post ( Bookmark it and use it as a reference in the future.

In this 41 minute video you’ll find:

  • 02:08 to 03:22 — Add the jQuery UI library to the page.
  • 03:23 to 04:40 — Explaining how elements get re-arranged.
  • 04:40 to 08:02 — Make region/report sortable.
  • 08:02 to 16:04 — Identify the elements to sort and explaining how we actually capture the new order.
  • 16:05 to 24:17 — The AJAX call to save changes (plus some debugging), wrapping up.
  • 24:18 to 42:25 — Implementing the same thing on a regular Classic Report.

Part 4: Adding Drag & Drop functionality from Jorge Rimblas on Vimeo.

* Music licensed from Envato’s AudioJungle.

Posted in APEX, Classic Reports, Javascript, JavaScript, Oracle, Video, Web

Implementing Drag & Drop in your APEX applications


I first learned how to implement Drag & Drop functionality from Doug Gault’s presentation at Kaleidoscope 2010 (yes before it was Kscope) “Replicating NetFlix Queue Drag-and-Drop Functionality with Oracle Application Express/jQuery” (Membership required). I mean, I wasn’t actually there, but the presentation has excellent step by step instructions. My goal is for this post to become a useful quick reference guide (as much for me as others).

With the proliferation of mobile apps and being fully into (probably the end of) Web 2.0, users come to expect this sort of feature more and more. When we implement it in our Oracle Application Express applications, it brings a nice “wow” factor. That said, I don’t think it’s for every scenario, and I would not overuse it. Also, keep in mind, on mobile devices, you may need some extra libraries to fill in for the lack of a mouse.

If you’ve seen some of my videos, Part 1 covers the creation of the template that is mentioned below. In video installment 004, I following these instructions. If you have any questions, hopefully, the video will cover them.

Demo app here.

Structure to Sort “Lines”

You’ll need a parent container that includes the sortable lines.
For a report think <TABLE> as the container and <TR> as the lines.
For a list think <UL as the container and <LI> as the lines.
The lines that are to be sorted require some ID that uniquely identifies them. You can use a real id tag (id="line123") attribute or a dataset attribute like data-id. The dataset approach is more robust as HTML id values cannot start with a number.

We’ll use a markup like the following:

We’ll define a “Named Column” report template to define the UL list. (To see how to do this watch Part 1)

“Before Rows”

“Row Template 1″

“After Rows”

We’ll use the following table to hold our data:

The DISPLAY_SEQ is the value we’ll use to sort and to re-arrange after a drag & drop action takes place.
The following SQL will define our Classic Report with the custom Named Column template. Give the report a Static ID, we’ll use todoRegion

Include the sortable jQuery UI library

This library is already part of your standard APEX distribution. Select the correct one for your version of APEX

APEX 4.2

APEX 5.0

Make the report Sortable

Notice this.affectedElements[0] which means you’ll use this within a Dynamic Action and specify your report region as the Affected Element.
containment (line 4) is optional, but sometimes it’s a helpful option to restrict how far the elements can be dragged. Try it without to see the effect.
At this point, the report lines can be dragged, but their new order won’t be saved because we have not defined updateDisplaySeq()

The 'toArray' method will return an array with the ID of our lines. Then .toString() makes it easier to work with in our AJAX process.
By default toArray looks for the element ID, since we’re using data-id we need this option: {attribute: 'data-id'}
The code for UPDATE_ORDER will follow, but notice line 8. If we were using the old Notification Plugin from Oracle (that uses Gritter) we could generate a Notification to the user that the new order has been saved. You could consider using pNotify instead.
Finally, line 9 forces an APEX Refresh of the report to ensure all the latest data is in place and fresh.

AJAX Callback

This is the AJAX Callback reference in the code above as UPDATE_ORDER. Remember that the AJAX Callback name is case sensitive.
The following code receives x01 with our string of comma delimited ID in the new order we want.


If you’re using a standard Classic Report (instead of a Named Column template that you can control). You’ll need to add the ID handles to your <tr> rows.
The following code will find the ID column (it could be a link column). You’ll want to have this snippet in the attributes data-id=#ID#.
It will extract it from a dataset attribute and add it to the TR tags.
You will need this code defined as a function because you’ll call it after Refresh to re-insert the ID to the report.
pRegionID is the Static ID of the report. The first selector for $r may need to be adjusted depending on the theme.

fixHelper is very useful for a table report as it will set the width or the TR being dragged to the original width it had. Said another way, it will maintain the width of the row being dragged. Without it, the row may collapse to the width of its elements. You can see it’s being referenced in the helper parameter as part of the sortable constructor.

The selector inside updateDisplaySeq (called above) will need to be changed to work with a table. Something like this should work for you:

Posted in APEX, Javascript, Oracle, Web

Video: Part 3 – Adding styling with CSS

Before & After with CSS

This video is all about CSS styling.

You’ll see me working on the list created in the previous episodes (Part 1 and Part 2) and transform it to something a lot more interesting.

In this 42 minute video you’ll find:

  • 02:30 to 10:20 — Style the list container and setup the structure.
  • 10:21 to 19:00 — Style list elements.
  • 19:01 to 37:20 — Style the controls within a list element including hover states.
  • 37:21 to 38:52 — Using HSL to find colors.
  • 38:53 to 42:25 — A little border, saving CSS with the Theme Roller, and wrap it all up including the before and after.

Part 3: Adding styling with CSS from Jorge Rimblas on Vimeo.

Coming next… Drag & Drop!!!

Oh, one last thing, did you like the new video bumpers? I’m pretty excited about them.
Music licensed from Envato’s AudioJungle.

Posted in APEX, Classic Reports, CSS, Oracle, Video, Web

Video: Part 2 – APEX Classic Report Named Column Templates

I’m happy to bring you installment Number 2 of this video series. If you missed the first one, you can find it here Part 1.

We’ll call this the “Dynamic Action” edition because that’s what most of the video deals with.

In this 39 minute video you’ll find:

  • 0:00 to 5:49 — Fix a bug from part 1.
  • 5:50 to 30:49 — Add ability to toggle the todo checkboxes by just clicking them.
  • 30:50 to 39:00 — Add a “Trash” icon to delete a todo entry.

Part 2: APEX Classic Report Named Column Templates from Jorge Rimblas on Vimeo.

At around 13:23 some sort of noise affected the recording. Not sure why. Unfortunately, it did affect the quality of the rest of the recording. I’ll have to look into that and resolve it before recording 003.

Next: Part 3

Posted in APEX, Classic Reports, Video

Video: Part 1- APEX Classic Report Named Column Templates

As part of my Kscope16 presentation “Hooked on Classic (Reports)
Learn tips & techniques to make them sing” (live slides here). I demoed a Classic Report with a custom template (a Named Column template), made to look like a list. I thought it would be useful to show all the steps of how that demo was built.
The full video is 36 min. however, only the last 16 min are for the building of the template example. When you’re done with this one, watch the follow-up video where I extend the functionality with some useful Dynamic Actions.

Note: If you only care about the building of the template, skip to min 20 in the video.

APEX Classic Report Named Column Templates from Jorge Rimblas on Vimeo.

If you like this format, and you like what you see, please let me know in the comments or twitter.

Next: Part 2

Posted in APEX, Classic Reports, KScope, Oracle, Video


You may be familiar with the UNION operator in Oracle SQL, but are aware of the UNION ALL operator?

Perhaps you will be surprised to hear that more often than not when you write UNION, what you meant to use is UNION ALL.

The UNION operator is used to combine result sets from multiple SELECT statements into a single result set. However, it eliminates duplicates in process.

In order for the database to do this the database will need to join the two result sets, sort them, find the duplicates and eliminate them.

Hey wait a minute, sort the results? Yes, the most efficient way to eliminate duplicates is to order the results and then find the duplicate entries. To make matters worse, if you have a “large” amount of data, this sort operation may not be able to be performed in memory (which would be the most efficient approach).

UNION ALL on the other hand will combine the result sets as they are. It will return all rows.

There’s clearly a use case for both scenarios. However, I would submit to you, more often than not, what we really want is to combine all the rows.

Be aware, that when using UNION you’re asking the database to do more work, make sure that’s what you really want.

I know that if you search for UNION vs UNION ALL you’ll find a gazillion results. But hey, I keep seeing UNION misused, so maybe we need one more blog about it.


Posted in Oracle

Winds of Change

After three and half years at Enkitec, the last 1.5 of those years as Accenture Enkitec Group, it’s now time to make a change. It has been a great ride with a lot of highs, success, and accomplishments. I couldn’t be more thankful. It’s right up there with one of the best decisions I’ve made in my career. I made many new friends and learn from some of the best and brightest people in the industry.
However, change can be powerful and positive. I’m excited to announce I’ve accepted a position with Insum Solutions. This new adventure starts on February 1st, 2016.

The decision didn’t come easy, but a move to a company dedicated to APEX, full of APEX Experts (and Oracle Specialists) gets my blood pumping. I’m excited about the new challenges and opportunities. To me, this move is about my interest, excitement, and commitment to Oracle Application Express. #LetsWreckThisTogether !

Posted in Uncategorized

Using Select2 on APEX tabular forms

I love the Select2 jQuery plugin. It’s a feature rich, good looking, select list replacement. As an APEX developer, it makes sense to use the excellent plugin from Nick Buytaert. Since its announcement, in Aug 2013, you would be hard pressed to find an APEX application where I don’t use it.

All that said, APEX doesn’t (yet) support plugins on tabular forms. This blog post is about documenting the JavaScript and Dynamic Actions (DA) you could use to use it as part of a tabular form.

The Quick and Easy Approach

If your tabular form contains a Select List already, this method is for you. It will work whether you used a Column Type of “Select List” or APEX_ITEM in it’s various forms: apex_item.select_list , apex_item.select_list_from_query or apex_item.select_list_from_query_xl.

  1. You include the Select2 library on the page. (more on this in a moment)
  2. You target your Select Lists with jQuery and run the .select2() method on them. Yup, that’s it.

Step #2 may look like this:

or if you have any options to include:

Check out this demo. (Click on the “Apply Select2” button).

The button runs a simple DA that runs the code above. Notice that, if you’re using the Universal Theme in APEX5 you may want to remove the select list styling applied by the class “u-TF-item–select”. Use a command like this:

Let’s talk about #2 above. In order to include the Select2 library on the page, I like to “cheat” whenever possible and have at least one Select2 APEX item plugin on the page. Doing this will include all the JavaScript and CSS that you need to run the .select2() method. That’s exactly how the previous demo page works.

The (slightly) Messy Approach

However, if it’s not possible or desirable to include a regular Select2 item on your page, you’ll have to manually add the necessary libraries. This can get a little tricky if say for example you download the Select2 jQuery files, they don’t match the version used by the plugin, and then later you add a Select2 item plugin to the page.  You’ll want to be careful with that.  For this reason, I like to use the same files that the Select2 item plugin is using. That’s also not ideal because you could upgrade the plugin and then again be in conflict with the versions. My preferred approach is to move the file includes of the Select2 APEX plugin to their own procedure. Share that new procedure between the Select2 APEX plugin and my own, simple, “Manual Select2” plugin. You always move all plugin code to a package don’t you? (perhaps that’s a conversation for a different blog post).
This new “Manual Select2” plugin is what we’ll use to initialize the select lists on a tabular form.

My new procedure with the includes looks like this:

The original Select2 plugin changes to something like this:

For the new plugin, we’ll use a Dynamic Action type plugin with an Initialize category. It will have only one custom attribute for the component. The attribute will be used to contain the code that will initialize the select2 items.

Select2 Manual Plugin

When we use the plugin, the code “JS Function” can look like this:

Or it can be a lot more complicated, for example:

As you can probably tell from this code, you’re not limited to using this on tabular forms. With this technique you can use the full power of the Select2 plugin, like for example using the formatResult or formatSelection options that allow you to specify a function that formats how the values are displayed.

This technique does require some trial an error, but hopefully it gives you a starting point to extend the capabilities of your applications.

Check out the demo using the Manual Select2 plugin approach.
Here’s the plugin dynamic_action_plugin_com_enkitec_manual_select2.sql.

The code code of the Manual Select2 plugin looks like this:

It basically takes the code you provide (the code to initialize select2), wraps it with a function and calls it on page load.

If you provide the code:

The function will look something like this (additional formatting added for clarity):


UPDATE Feb 7, 2016: I’ve added a new fully working example implementing Lazy Loading.


Posted in APEX, Javascript, Oracle, Plugins

Fill the Glass: Measuring Software Performance

I had the delight of participating on a “Fill The Glass” webinar (#FillTheGlass). Fill the Glass is a new style of, technology related, webinar series by Cary Millsap.

Cary Millsap is a developer, teacher, writer, and consultant who has been a part of the Oracle ecosystem since 1989. His new webinar series about Oracle and related technologies is going to be little different than the usual hello-slide-show-Q&A-bye routine. These shows are going to include conversation. Our aim is to bring the technology to life. Our guests will of course talk about the problems they’re solving and how they solve them, but our conversations will include discussions about their ideas, their motives, their tools, …even their careers. Cary likes to find the twist, a way of perceiving a situation that you might not have thought of. Join us to learn, improve your career, and have some fun.

In this episode of Fill the Glass, Cary and I discuss techniques for measuring software performance. Some of the topics include instrumenting your code, measuring workloads, SQL Plan Management (SPM) and code development ideas in general that you may be able to apply to your projects.
Although the application in the video was built with Oracle Application Express, the concepts are universal to programming. At the very least, very current and apropos for Oracle developers of any kind.

The recording is now available here:

Fill the Glass Episode 4 with Jorge Rimblas – Measuring software performance in the real world from Enkitec LP on Vimeo.

Related links of topics seen or mentioned during the webcast:

Posted in APEX, Interviews, Oracle, Video

Expert Oracle Application Express 2nd Edition

I’m really excited to share with you that the 2nd Edition of APRESS Expert Oracle Application Express (Amazon link) is now released. Some of the concepts in this book may apply to previous versions of APEX, but this book was created with APEX5 in mind.

Expert Oracle Application Express

This book is the result of hard work from 14 authors: Doug Gault, Tom Petrus, Denes Kubicek, Roel Hartman, Dan McGhan, Francis Mignault, Raj Mattamal, Martin D’Souza, Christoph Ruepprich, Dimitri Gielis, Nick Buytaert, Karen Cannell, John Scott, and myself.

I should also mention the expert help of the APRESS team and the technical reviewers: Patrick Cimolini, Vincent Morneau, and Alex Fatkulin.

By the way, all but one of those authors and technical reviewers are on Twitter. If you’re an Oracle professional and work with Application Express, I recommend you follow them.

The book is comprised of 14 chapter over 650 pages.

1. APEX Builder, Denes Kubicek
2. Oracle REST Data Services, John Scott
3. Oracle APEX 5.0 Charts Inside Out, Dimitri Gielis
4. Tabular Forms, Denes Kubicek
5. Team Development, Roel Hartman
6. Globalization, Francis Mignault
7. Debugging, Doug Gault
8. Dynamic Actions, Martin Giffy D’Souza
9. Lifecycle Management, Nick Buytaert
10. Plug-Ins, Dan McGhan
11. jQuery with APEX, Tom Petrus
12. Map Integration, Christoph Ruepprich
13. Themes and Templates, Jorge Rimblas
14. Report Printing, Karen Cannell

One more piece of information. All proceeds from this book go to the families of two exceptional people that left us way too soon: Carl Backstrom and Scott Spadafore. Both members to the APEX team and instrumental in laying the foundation that has gotten Application Express to where it is today. Although I never met them in person, their knowledge sharing and efforts in the community to help people like me better learn and use APEX helped me immensely.

Posted in APEX, Oracle

Oracle APEX

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.