Skip to main content

Command Palette

Search for a command to run...

Popup LOV custom template

Updated
4 min read
Popup LOV custom template
L

Oracle APEX Developer (Insum) from Paris Contributor of Flows for APEX Passionate about APEX and web development.

Popup LOV item type

One of my favorite item type in APEX is the popup LOV, users love it because of the ability to search even across multiple columns since version 19.2. It supports single and multiple value selection and can be displayed as an inline popup or a modal dialog.

By default, APEX displays the popup LOV as a list when there is only one column and as a grid when there are several columns. popup_lov_default.png

Create a multiple columns popup LOV

For this example I have the list of the COVID19 vaccine center in France, I want to display the name of the center, the address, the zip code and the city. Start by creating a list of values in Shared Components with this query

select 
     id
   , name
   , street_number
   , street
   , zip_code
   , city
from vaccine_center

Then, in the page, add a new item, choose Popup LOV as type and select the LOV under List of Values section attribute. The item should be displayed like this. default_addresses.png So how do I change this, if I want the information to be displayed on 3 lines?

Define a custom template

Under the Javascript Initialization Code attribute, you can change the options object to be used during the initialization of the popup LOV. I had trouble finding the correct substitution syntax, but once again, John Snyder wrote something useful about it in his blog post All the Things That Pop Up. Take a look at the sample application, if you want to have more details.

function(options) {
    options.display = "list";

    options.recordTemplate = (
  '<li data-id="~ID.">' +
     '<div class="content-address">' +
         '<span class="center-name">~NAME.</span>' +  
         '<span class="center-address">~STREET_NUMBER. ~STREET.</span>' +   
         '<span class="center-city">~ZIP_CODE. ~CITY.</span>' + 
     '</div>'+
  '</li>').replace(/~/g, "&");

    return options;
}

The item should be displayed like this now.

covid19_without_css.png Not so bad, but we can make it better by applying this simple CSS rule to the page (learn more about flexbox here

.content-address {
      display: flex;
      flex-direction: column;
}

And like magic, the popup LOV is now displayed in 3 lines as I wanted. custom_addresses.png

Advanced examples

Here is two examples, one is a simple user list with small avatars and the second one is a cards list with avatars and icons. popup_lov_custom.png

List of values

In this two examples, I use the same list define with this query. Datas comes from randomuser.me which provides an API to get a list of users. Really cool when you want to build some demos!

select 
      u.id
    , u.first
    , u.last
    , u.email
    , u.phone
    , u.large as picture
    , u.country
    , u.city
    , u.age
    , u.date_ as birthdate
    , u.first|| ' '|| u.last as full_name 
from user_data u

Simple List with Avatars

Javascript Initialization Code:

function(options) {
    options.display = "list";

    options.recordTemplate = (
  '<li data-id="~ID.">' +
     '<div class="content-list">' +
        '<img class="avatar-list" src="~PICTURE." alt="User Avatar" loading="lazy">' +
        '<div class="user-infos-list">' +
           '<span class="user-name"><b>~FIRST. ~LAST.</b></span>' +                    
        '</div>' +
     '</div>'+
  '</li>').replace(/~/g, "&");

    return options;
}

CSS code:

.avatar-list {
  border-radius: 10px; 
  width: 50px;
  height: 50px;
}

.content-list {
  display: flex;
  flex: ;
  flex-direction: row;
}

.user-infos-list {
  margin: ;
  margin-top: 15px;
  margin-left: 15px;
}

Cards with Avatars and Icons

Javascript Initialization Code:

function(options) {

    options.display = "list";

    options.recordTemplate = (
        '<li data-id="~ID.">'+
            '<div class="card">' + 
                '<img class="avatar-card" src="~PICTURE." alt="User Avatar" loading="lazy">' +
                 '<div class="user-infos-card">' +
                     '<span class="user-name-card"><b>~FIRST. ~LAST.</b></span>' +
                     '<span class="user-info-card">' +
                         '<span class="fa fa-globe user-info-card-icon" aria-hidden="true"></span>'+
                         '<span class="user-info-value">~COUNTRY.</span>'+
                     '</span>' +
                     '<span class="user-info-card">' +
                         '<span class="fa fa-phone user-info-card-icon" aria-hidden="true"></span>'+
                         '<span class="user-info-value">~PHONE.</span>'+
                     '</span>' +
                     '<span class="user-info-card">'+
                         '<span class="fa fa-envelope-o user-info-card-icon" aria-hidden="true"></span>'+
                         '<span class="user-info-value">~EMAIL.</span>'+
                     '</span>' +                        
                 '</div>' +
            '</div>'+
        '</li>').replace(/~/g, "&");

    return options;
}

CSS Code:

.user-infos-card {
  margin: 1rem 1rem 1rem 2rem;
}

.user-name-card {
  margin-bottom: 1.5rem;
}

.user-info-card-icon {
  margin-right: 1rem;
}

.user-info-card {
  margin-bottom: 0.5rem;
}

.card {
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    transition: 0.3s;
    display: flex;
    flex-direction: row;
}

.card:hover {
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}

.user-infos-card {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  margin: 1rem;
}

.avatar-card {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: solid 5px greenyellow;
    margin-left: 1rem;
    margin-top: 0.85rem;
}

What next?

Now, your imagination is the only limit to display nice popup LOVs in your application! You can find the live demo here

I hope you enjoyed these tips!

Comments (10)

Join the discussion
M

That's Working, thank you so much!

M

How to show the Images within the Display Values if I choose Static Values ?

D

Hi, thanks for sharing this. One thing though, I can't access the demo app using the credentials on the login screen. Can you please check on that?

1
L

Hi Daniel Marasigan, Thank you for your comment and for letting me know that the demo user was unable to login anymore. It is fixed now!

A

Hii all this is Arun ur blog was extremely good but I am new to Oracle apex ~NAME. Is this static id of that column

Can anyone please respond quickly please I don't have enough time actually

L

ARUNKUMAR CN yes it's the column name in the query

A

Louis Moreaux Yeah thank you very much I thought that is the static id u mentioned under the Advance settings

A

I have one doubt in interactive grid I have added dynamic calculation between columns when I entered Amount and quantity I will get automatically total amount for grand total I have used to sum of total columns

The problem is whenever I deleted the row from grid the grand total page item is not getting actual grand total by excluding that deleted row

Can u please suggest me through this requirement

L

ARUNKUMAR CN please post your questions on the forum or the slack channel when it's not related to the blog post. Thanks

A

Louis Moreaux Thank you soo much

A

Louis Moreaux Louis Moreaux Hii Louis U know how to make apex input fields like how we can see input fields in Email Is this possible

actually I tried alot in Oracle forums but no-one helped with this requirement can u please

L

Hey Louis! I'm currently trying to implement the Simple List with Avatars on Oracle APEX 23.2.3 and it's not working. All the columns are correct and the URL of image is valid. Is it some version update issue? Or is there a new option? Thank you!

1
L

Hi Lázzaro Daudt da Costa, I just checked it and the demo page is still working on the latest version. It's probably something else. Did you see any JavaScript error in the console?

L

Louis Moreaux Yes, when opening the Popup LOV:

Uncaught TypeError: this.data$.iconList is not a function

L

Lázzaro Daudt da Costa Are you able to duplicate this error in apex.oracle.com? Which Oracle APEX version are you using?

N

Wicked Awesome Tip Brodha. Merci Beaucoup.

1
L

Happy you like it Neelesh! Avec plaisir!

S
Sandeep2y ago

Hey Louis, This is great. I have another requirement where in i want to restrict the query in the shared component LOV at run time. For example there is an item :p100_Customer

my shared component LOV is SELECT order_number, shipment_date, shipped_qty FROM table;

When my LOV is parsed i want to restrict it like below SELECT order_number, shipment_date, shipped_qty FROM table WHERE customer = :p100_customer;

L

Hi Sandeep,

Thank you for the comment, I am glad you like it!

You can use the bind variable in your shared LOV but don't forget to pass the item value in your page under Cascading List of Values attributes.

S
Sandeep2y ago

Louis Moreaux Thanks so much for the reply. I have tried this already, I was unable to see any cascading LOV attributes but still i went ahead and updated it, it did not work

L

Sandeep You should do what is explained in this video https://youtu.be/80GCL9lm4ZE

S
Sandeep2y ago

Great.. Louis Moreaux Thanks so much. that helps

If you don't mind can i ask one more help, Iam trying to bring the interactive grid records (in a popup modal) to lines table. User will be selecting records with check boxes in the popup. If you have done any videos in the past please help with the reference.

S
Sandeep2y ago

Louis Moreaux Hey Louis, There is a concern here, Actually i am not using the shared component LOV from the page item. The shared component LOV is on one of the columns in interactive grid at the lines level and i am unable to pass the value from the header level which is needed to restrict the LOV.

J

Louis, this is a great tip. Thanks for taking the time to share, we are looking to utilise this in our own application

1
L

Hi James, Thanks for your comment, I really appreciate it!

J

Hey Louis, thank you for sharing this. Today this helped me and made it a snap to implement in my application.

2
L

Hi Jorge, really happy to hear that. Thank you for the feedback!

A

How can I download the application

L

Hi, I do not plan to make this application available. But you should be able to duplicate the examples in your application. I will be more than happy to help you if you need to.

More from this blog

Oracle APEX tips and tricks - Louis Moreaux

32 posts