Oracle APEX 4.0: Cascading LOVs/Select Lists

Oracle APEX 4.0: Cascading LOVs/Select Lists

One of the new features of Early Adopter 2 are Cascading LOVs/Select Lists. I’m pretty sure that almost every APEX developer had already the requirement to refresh a child select list when a parent select list was changed. For example you pick a department in the first select list and the second should just show employees of that department. There are two solutions to solve that:

  1. Use a “Select List with Submit” for the department field, which will automatically submit and refresh the page when a department is picked. In the Web 2.0 world that’s a little bit outdated and it can also takes quite long to refresh the full page. You also have to take care that your validations and processes do not fire in that specific case. So quite a number of extra conditions are necessary to deal with the auto submit. This solution doesn’t really make the page more maintainable and the user experience is also not very great.
  2. But you have heard about the holy grail AJAX anyway. It’s the way to go! The idea is to just refresh the child select list by calling the server to get a restricted list of employees and use browser DOM manipulation to replace the existing select list with the new values. Much better user experience! No full page refresh, the employee select list just magically changes. But it doesn’t come for free. If you have a look at all the Cascading LOV examples which are out there you will notice that you have to write quite a bit of JavaScript code and an On-Demand process which duplicates your LOV statement. So this solution offers great user experience but again makes your page hard to maintain. And I’m sure it will takes you more than 5 minutes to implement that solution…

So both solutions are not really satisfying because the require quite a bit of coding, which makes the application harder to maintain. But with Oracle Application Express 4.0 there is now a third solution for the problem. It gives the user a great UI experience and doesn’t require any additional coding!

Declarative “Cascading LOV” support for all “List of Values” based item types! That means select list, checkbox, radio group and shuttle based page items can automatically be refreshed if a parent field gets changed. (Note: Popup LOV and List Manager will be added as well in the final product) Important to mention here is that the parent field doesn’t have to be a select list, it can be a simple text field, date picker, … as well. Every DOM element which fires a change event will work as parent.

To add “Cascading LOV” support for a child page item, you just have to set the new “Cascading LOV Parent Item(s)” attribute in the “List of Values” section to the name of your parent page item. That’s it! This will tell APEX to automatically refresh the page item with new values each time the parent item gets changed.

Cascading LOV settings

So let’s create a simple example where we first select a department and then an employee in that department.

  1. Create page item P2_DEPTNO of type “Select List” with the following LOV statement
    select dname,
           deptno
      from dept
     order by 1
  2. Create page item P2_EMPNO of type “Select List” with the following settings
    • Cascading LOV Parent Item(s): P2_DEPTNO
    • List of values definition:
      select ename,
             empno
        from emp
       where deptno = :P2_DEPTNO
       order by 1

That’s all! Super simple as it should be.

If you have a look at the screenshot above you will see that Cascading LOVs have the attributes “Page Items to Submit” and “Optimize Refresh” as well. Most time you will probably not need to set them. For details about them consult the page item level help.

Check out my New Features Sample Application for the above example and a more advanced one with multiple levels and a shuttle.

19 Responses to “Oracle APEX 4.0: Cascading LOVs/Select Lists”

  1. Tobias Arnhold Says:

    This problem sounds familiar to me! ;D I will check this out soon…

    Thanks Patrick for all the effort you are putting into the new APEX release.

    Tobias

  2. Milind Says:

    I like this feature as I used to struggle a lot for doing same thing in HTML DB 2.0 or Apex 3.1.2 using Ajax.

    It makes more similar to Oracle Forms LOV.

    Thanks Patrick for highlighting helpful feature of Apex 4.0 as I miss even after looking EA2 release.

  3. Zulqarnain Says:

    Hi

    In our applications in Apex 3.x we used your ApexLib and that solved this problem for us for select lists. But there was a limitation that it did not work for tabular forms. Is this limitation also with Apex 4?

  4. Robert Says:

    Superb. This will save a lot of people a lot of time.

  5. Angelos Says:

    Hi Patrick,

    will the Cascading Lists feature be available for Tabular Forms?

  6. Kishore Says:

    Great feature. Cascading LOVs are lot easier with this.
    First time I run the page, Employee LOV doesnt show results. It is being refreshed when change department.

  7. Patrick Wolf Says:

    Not sure yet if cascading LOV support for tabular forms will make it into APEX 4.0. But we will try hard.

    Regards
    Patrick

  8. Learco brizzi Says:

    Thanks! I used it a lot in 3.x. Every time it costs a lot of coding. This makes it just the way we want it.

    Learco

  9. Zulqarnain Says:

    > Not sure yet if cascading LOV support for tabular forms will make it into APEX 4.0. But we will try hard.

    Please make in available in Apex 4, since Tabular forms are considered a little weakness in Apex. I mean they are not as powerful and easy as the non-tabular forms. Making cascading LOV available in tabular forms will provide some ease.

  10. Martin Koeb Says:

    Hi Patrick,

    a great job – that’s what will make among others the APEX development easier and more efficient :-)

    Best regards
    Martin

  11. Dean Attewell Says:

    Please make it a std option.. that is so.. clean..

  12. allen Says:

    any ETA on the release of APEX 4? can’t wait. =)

  13. lester Says:

    Is the LOV appearance final? Please make it customizable… Thanks.

  14. Patrick Wolf Says:

    What do you exactly mean by customizable? Because you can already change it bu modifying the Popup LOV template of your theme.

    Regards
    Patrick

  15. Ram Says:

    Patrick,

    That’s great feature. Will this work on Table based cascading select LOV’s? I mean for each row like this.

    Dept (select list) Emp (select list)
    HR Miros, Steve
    OPS Stic, Pat

    etc

    Ram

  16. brenda Says:

    I have a dependent select list. When I choose a selection from the parent list, the page submits and then give me values for the child list, which is what I want. However, when I select from the parent list, I get an error that the child list must have a value. How do I avoid the error as it is a false error.

  17. Patrick Wolf Says:

    Are you using APEX 3.x or 4.0?

  18. Simon Says:

    Hi Patrick,

    Is the Apex 4.0 will support new DYNAMIC ACTION in tabular form?

    Regards,

Trackbacks/Pingbacks

  1. [...] new features as well. If you haven’t checked it out yet, I recently blogged about the new Cascading LOV feature and the updated Plug-in sample application which contains process type plug-ins as well. But first [...]

Leave a Reply