This discussion is archived
11 Replies Latest reply: Dec 17, 2010 4:55 PM by Juergen RSS

how do I refresh a select-list using a dynamic action?

jort Newbie
Currently Being Moderated
Here is my scenario.

I have a page with a database form. One of the items is a select-list. I want to refresh this item dynamically. I have created a dynamic event that fires, but it does not refresh the select-list. The little java icon just spins and the select-list remains empty even though it should have several options.

I tried putting the select-list item in its own region and did a region refresh. This does not work either.

So for some reason I cannot refresh a select list page item or the region. I mocked up a report region on the same page (just for testing), the dynamic event CAN refresh the report region just fine.

Josh
  • 1. Re: how do I refresh a select-list using a dynamic action?
    773431 Journeyer
    Currently Being Moderated
    Josh,

    Which version of APEX are you using? If you're in 4.0 or 4.0.1, you don't need a dynamic action. Just set the "Cascading LOV Parent Item(s)" field to whatever item you want to trigger the refresh.

    -David
  • 2. Re: how do I refresh a select-list using a dynamic action?
    Sam_06 Pro
    Currently Being Moderated
    If you are using versions older than 4.0, you need to use AJAX and onDemand processes , here is an example I coded:
    http://apex.oracle.com/pls/apex/f?p=22716:7:2830379880918483:::7


    Sam
  • 3. Re: how do I refresh a select-list using a dynamic action?
    jort Newbie
    Currently Being Moderated
    David,
    I'm on 4.0.1

    In this case, I don't have a cascading LOV. I just want my one LOV to refresh because I've added a new value elsewhere on the page. Are you suggesting I use the cascading lov item as a way of triggering the refresh in conjunction with a dynamic action? Can you elaborate a bit on this idea?

    Josh
  • 4. Re: how do I refresh a select-list using a dynamic action?
    773431 Journeyer
    Currently Being Moderated
    Josh,

    Kind of, though without the (manual) dynamic action. The parent item of a cascading LOV does not need to be a select box--any page item works. The only question is when the child LOV updates--a text field, for instance, will cause the child LOV to update once it loses focus, rather than as you're typing.

    Of course, this does mean that if you're using javascript (for instance) to update a field value, you need to remember to fire the onchange() event yourself.

    -David
  • 5. Re: how do I refresh a select-list using a dynamic action?
    jort Newbie
    Currently Being Moderated
    David,
    Your concept worked like a charm.

    I'll lay this out for others to benefit from.

    Page Item for select list -- P1_FOO. I want this to refresh using a dynamic action.

    To make it refresh using a dynamic action, I first create a new page item (hidden) P1_FOO_DUMMY. Its sole purpose is for triggering the select list refresh.

    Now go back to the select list (P1_FOO) and make it cascade off this dummy item.

    Create your dynamic action, mine was a "Close DHTML plugin" event.

    My On-True action is "setValue" on P1_FOO_DUMMY and I set the value to a SYS_GUID(), but you can set it to anything you want because its just a dummy value. I doesn't matter what you set it to.

    When the event fires and I set the value for the dummy item, this automatically makes the select-list refresh because of the cascade effect. Works great.
  • 6. Re: how do I refresh a select-list using a dynamic action?
    773431 Journeyer
    Currently Being Moderated
    Josh,

    Glad it worked. I'd assumed that you were wanting to refresh your list based on a value in the other page item, which is why I was saying to not bother with a dynamic action. Glad you were able to make it work!

    -David
  • 7. Re: how do I refresh a select-list using a dynamic action?
    Patrick Wolf Employee ACE
    Currently Being Moderated
    Hi Josh,

    you can even simplify further.

    1) It's not necessary to actually create a dummy hidden P1_FOO_DUMMY page item.
    2) In your P1_FOO set "Cascading LOV Parent Item(s)" to a non existing P1_FOO_DUMMY page item.
    3) Set "Optimize Refresh" = No (Note: that's very important so that the select list is always refreshed independent of parent values!!! Because in our case that the parent would be null)
    4) Just use the "Refresh" dynamic action.

    Note: in 4.0.2 the above steps will not be necessary anymore, you will be able to refresh any LOV based item type like select list, checkbox, radiogroup or shuttle without having to fake a cascading LOV.

    Regards
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf
  • 8. Re: how do I refresh a select-list using a dynamic action?
    jort Newbie
    Currently Being Moderated
    Patrick, sounds great. I'll put that on my 4.0.2 todo list when it comes out.
  • 9. Re: how do I refresh a select-list using a dynamic action?
    Juergen Newbie
    Currently Being Moderated
    Hi Patrick,

    we just got 4.0.2 and we always have the need for LOVs which are based on each other not only the typical cascading LOV, but having following structure as single LOVs e. g.

    Continent
    Country
    Region
    Division

    I should be able to select a Division and all other 3 LOVs should refresh, the same when I select a country, the Continent, Region and Division should be refreshed based on the selected country and so on.

    Is there any Dynamic Action Solution for this, because we need this structure 80% in our Sites and in 100% of our projects...

    Thanks, Juergen
  • 10. Re: how do I refresh a select-list using a dynamic action?
    Patrick Wolf Employee ACE
    Currently Being Moderated
    Hi Juergen,

    so your select list are actually not restricted and you just want to automatically pick a value in another select list based on the current value? In that case you would register a dynamic action with the "Change" event and use a "Set Value" action.

    Or do you mean something different? Can you provide us the SQL statements of your select lists? Maybe that will explain it better. BTW, you can also always trigger a refresh of a select list with the "Refresh" dynamic action.

    Regards
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf
  • 11. Re: how do I refresh a select-list using a dynamic action?
    Juergen Newbie
    Currently Being Moderated
    Thanks Patrick,

    I am still struggling with the Dynamic Actions..., its a great feature..., but you have to think differently, just like OOP programming vs. Procedural Programming.

    I have found a simple and fast solution, I am generating a collection with a flat structure of all the select lists hierarchy and filter the whole collection with the current LOV values, so all select lists have the appropriate values anytime and it is increadibly fast..., and I am using Dynamic Actions for resetting part of the hierarchy..., I love it... :)

    Juergen

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points