4 Replies Latest reply on Oct 12, 2012 8:08 AM by Mark BT52

    Skillbuilders Super LOV, refreshing SLOV list of values dynamically

    Mark BT52
      Hi, Another question.

      I have 2 SLOVs. The 1st is a parent of the 2nd.

      The first has its value changed dynamically for some reason.
      I cannot then dynamically change the value of the 2nd until the cascading effect is triggered by opening up the 2nd SLOV via the button.

      So if the page has LOV1 with value 'A' with LOV2 having child values 'A1', 'A2', 'A3' available and I then do the following

      $('#P1_LOV1).apex_super_lov('setValuesByReturn', 'B'); (where B is a valid value)

      followed by
      $('#P1_LOV2').apex_super_lov('setValuesByReturn', 'B1'); (assuming B1, B2, B3 are child values for B)

      then it doesn't work.

      In fact
      $('#P1_LOV2').apex_super_lov('setValuesByReturn', 'A1');
      $('#P1_LOV2').apex_super_lov('setValuesByReturn', 'A2');
      $('#P1_LOV2').apex_super_lov('setValuesByReturn', 'A3'); DO still work, even though the parent is now wrong.

      So basically it appears that dynamically changing the value of the parent SLOV is not triggering the cascade effect that choosing manually from the SLOV itself does.

      Is there any way to force the cascading child list of values to refresh after changing the parent dynamically?

        • 1. Re: Skillbuilders Super LOV, refreshing SLOV list of values dynamically
          Tom Petrus
          I take it we're talking about a next step after {thread:id=2449494}

          What i did there to have a change trigger through to the 2nd lov was bind to the .change event of the first lov. The change event does not fire however when you set a value to an item through javascript/jquery.

          If you hooked up a dynamic action or a manual bind to the change event on EMP (example)
          $("#P1_LOV2").apex_super_lov('setValuesByReturn', $("#P1_LOV2_HIDDENVALUE").val()); 
          then you can use this code to trigger the change event manually: (.change())
          $('#P1_LOV1).apex_super_lov('setValuesByReturn', 'B').change();
          • 2. Re: Skillbuilders Super LOV, refreshing SLOV list of values dynamically
            Mark BT52
            Thanks for that. I'm struggling to figure out how best to use it for the situation I have though.

            I have set up a simple example again

            workspace: blobvideo
            username: admin
            password: fremantl3

            Application : video blobbing
            page : 14

            The first LOV holds default values for DEPT and EMP. These should populate the 2nd and 3rd LOVs.
            DEPT is a parent LOV to EMP, and EMP is restricted to display child values to DEPT.

            These defaults need to be overridable, hence they are LOVs as well.

            Your first solution for swapping the hidden and displayed values was fine for displaying the dept and emp values.

            But my problem now seems to be that the EMP lov is constrained to show child records to the DEPT one, hence wanting to 'refresh' the DEPT LOV on selecting a new default row.

            As it is it will only show EMP values that are valid for the DEPT lov as it originally was rather than reflecting the changed value.

            I have tried but I'm struggling to see how to use your code above in this situation.

            Many thanks

            Edited by: Mark BT52 on Oct 11, 2012 5:46 AM
            • 3. Re: Skillbuilders Super LOV, refreshing SLOV list of values dynamically
              Tom Petrus
              Hi Mark,

              Some issues with session state there! Your EMP lov is restricted to the records which match the DEPT value in session state. Initially this will be null and no values will match. Suppose you select a dept and submit the page, so the values are saved to session state. When you open the lov, the employees there would be only those for the dept whose value is stored in session state. Understanding Session State, Oracle docs

              You were on a right track with cascading lists, but it breaks your pick defaults functionality. So i blanked that out, i don't want the default functionality. We need to roll our own for this. Don't worry, not too much!

              First off, when dept changes due to a pick in either the defaults or dept lovs, the selected dept needs to go to the session state. This is necessary so the emp lov can find the correct records. So i added a dynamic action to fire on change of P14_CHOOSE_DEFAULTS and P14_DEPT. The true action is a PLSQL code execution. PLSQL is always serverside, and we can provide items to be submitted to session state. The code executed is simply
              because we don't need to execute anything, but P14_DEPT is set to be submitted to session state when the call is made.

              With these changes everything works. Only, EMP has to be blanked out when DEPT changes. Otherwise you could switch DEPT around but still leave in a wrong EMP.
              So i added another dynamic action which fires on change of DEPT and blanks out EMP. No worries about the defaults picking, as that will not fire a change due to values only being altered
              by javascript which do not fire change events.

              PS: please remember to assign helpful/correct answer marks to posts that are :-)
              • 4. Re: Skillbuilders Super LOV, refreshing SLOV list of values dynamically
                Mark BT52
                Great, thanks so much, I was really tying myself in knots trying to solve that!