9 Replies Latest reply: Feb 21, 2013 9:34 AM by Snoesky RSS

    Dynamic Form in Tabular Form i.e SET VALUE

    890243
      Hi,
      I have an tabular form ,
      In which two column are there i.e username and department
      Just I wnt to know can dynamic action i.e SET VALUE CAN BE USED IN TABULAR FORM.
      AS I CHANGE THE USERNAME THERE PERSPECTIVE DEPARTMENT SHOULD CHANGE.
      can anyone help.
        • 1. Re: Dynamic Form in Tabular Form i.e SET VALUE
          trent
          Hi,

          Shouldn't be too hard.

          Every input element has an f0x value. SO just figure that out. Create a new dynamic action for lose focus based on jQuery selector, which is:

          input[name="f03"] -- assuming it is f03.

          Create a true action of execute javascript code.
          var row = $x_UpTill(this.triggeringElement, 'TR');
          var otherElement = $('input[name="f04"]', row)[0];
          otherElement.value = 'somethingnew';
          You would obviously have some better logic for setting the new value.

          See implementation of that code here: http://apex.oracle.com/pls/apex/f?p=45448:11 (f03 is the name column)
          • 2. Re: Dynamic Form in Tabular Form i.e SET VALUE
            amckinne
            Hello Trent,

            I too, am attempting to set the value of an item when another item is changed.
            I need to capture the APP_USER changing the row for each row changed in the tabular form when submitted.

            My table is in a remote database that is not allowed to have APEX loaded directly in the instance (or db link TO the APEX instance).
            Can’t get the APP_USER making the change at this level, as the APEX code is not there.

            The instance that hosts the APEX installation accesses the table via a view through a db link.
            Can’t use a trigger on the view to set the APP_USER using APEX functionality.
            Not desirable to re-invent the IUD wheel using instead-of triggers.

            The example you posted on http://apex.oracle.com/pls/apex/f?p=45448:11 is exactly what I need (even though your example sets the value on Lose Focus and I Set value on Change).

            I am attempting to implement the dynamic action for the item using your javascript, and am almost there....but not quite. The dynamic action is updating the target item in ALL the rows in the tabular form, not just the one that is being changed.

            This, I am sure, is due to my inexperience with Dynamic Actions, jquery syntax, and the javascript API’s for APEX. I believe I know what the issue IS, I’m just not sure how to work around it.

            Please note: I attempted to download your example at the above website (turning off popup blockers), but had no success (I got the thank-you for downloading message, but have no clue what was downloaded to where). I was hoping to compare your form Dynamic action with mine to see where I went wrong.

            If you could please, review the following and:
            1)     let me know what might be different from your working example?
            2)     provide info on how to get your working form downloaded (such a tease to have the download link there and not get it to work ;0} ) , please?

            The following shows the html from view source for a row in my tabular form. This will help you get an idea of the items. The actual number of rows in the form is about 50.

            <table cellpadding="0" border="0" cellspacing="0" summary="" class="report-standard">
            ...
            <tr class="highlight-row">
            <td headers="CHECK$01" class="data">
            <label for="f01_0002" class="hideMe508">CHECK$01</label>
            <input type="checkbox" name="f01" value="2" class="row-selector" id="f01_0002" />
            </td>
            <td headers="JOBNO_DISPLAY" class="data">X111Y2222</td>
            <td align="center" headers="DEPR" class="data">
            <label for="f03_0002" class="hideMe508">DEPR</label>
            <input type="checkbox" name="f03_NOSUBMIT" value="1" id="f03_0002_01"
            onClick="if (this.checked) {apex.jQuery('#f03_0002').val('1');}
            else {apex.jQuery('#f03_0002').val('');}" />
            <input type="hidden" name="f03" value="" id="f03_0002" /></span>
            </td>
            <td headers="UPDUSER" class="data">
            <label for="f04_0002" class="hideMe508">UPDUSER</label>
            <input type="text" name="f04" size="16" maxlength="2000"
            value="MOMSDAT" id="f04_0002" />
            </td>
            <td headers="DERIVED$01" class="data">MOMSDAT</td>
            <td headers="UPDDATE" class="data">13-DEC-11
            <label for="f02_0002" class="hideMe508">JOBNO</label>
            <input type="hidden" name="f02" value="X111Y2222" id="f02_0002" />
            <input type="hidden" id="fcs_0002" name="fcs"
            value="DB31F7B9ED99E6A2F7295F6B7D236409">
            <input type="hidden" id="frowid_0002" name="frowid"
            value="AAATI3AAGAAAAIXAAo" />
            <input type="hidden" id="fcud_0002" name="fcud" value="U" />
            </td>
            </tr>.....
            <tr>.....</tr>
            </table>

            To help explain:
            I have a checkbox associated with array name f03_NOSUBMIT,
            This checkbox OnClick updates a hidden item associated with array name f03. The hidden item is linked to the depr column of my view/table (this functionality is straight from Oracle’s tabular checkbox wizard – works great, no problems).

            When the check box is changed, I need to capture the APP_USER value in the UPDUSER field associated with the f04 array (nice that the array names matched up with your example :0} )

            To do so, I created a dynamic action:
            Name: Set_Upduser
            Sequence: 10 (it’s the only DA)
            Event: Change
            Select Type: jQuery Selector
            jQuery Selector: input[name=”f03_NOSUBMIT”]
            --note: the event does not fire if I use f03
            --since that value is not actually
            --changed until submit with this
            --method.
            Condition: - No condition –
            True Actions:
            Sequence: 10
            Action: Set Value
            Fire When Event Result is: True
            Fire On page Load: Unchecked
            Stop Execution On Error: Checked
            Set Type: JavaScript Expression
            JavaScript Expression:
            var row = $x_UpTill(this.triggeringElement, 'TR');
            var otherElement = $('input[name="f04"]',row)[0];
            otherElement.value = '&APP_USER.';
            Selection type: jQuery Selector
            jQuery Selector: input[name="f04"]

            This ALMOST works...
            When I run the page and click on just one check box, the UPDUSER fields are updated with the APP_USER for ALL the records, not just the row for the checkbox I clicked. And, if I submit the changes, ALL the records in the table now have the APP_USER in the UPDUSER column. Not just the column where the check box was changed (Which would be expected since all the values are changed in the form – hey, the submit part works :0} ).

            Your example at http://apex.oracle.com/pls/apex/f?p=45448:11 works, setting the value for the target field only for that row. If I can get mine to work the same way, I will be good to go (as in hog-heaven, doing the Snoopy Supper-Time dance).

            I am thinking my issue is with the row identification in the
            --- var otherElement = $('input[name="f04"]',row)[0];
            I seem to not be picking up the row value in the row var.
            Am I reading line correctly where 'input[name="f04"]' is pNd, and row is pValue? Read the description of the $x_UpTill API, not sure how this is working to identify pValue (Row?).

            Additionally, I am not sure what the [0] is for at the end of the otherElement var definition. I don’t see that listed with the $ JavaScript API parameters (Google wasn't much help there either).

            OR, am I missing something else?

            Once again, if you could:
            1) let me know what might be different from your working example? (What does yours have that mine doesn’t)
            2) Provide any info on how to get your working form downloaded at http://apex.oracle.com/pls/apex/f?p=45448:11. Please, please?

            As always, your assistance is greatly appreciated!

            Edited by: amckinne on Dec 27, 2011 5:29 PM

            Edited by: amckinne on Dec 27, 2011 5:33 PM
            • 3. Re: Dynamic Form in Tabular Form i.e SET VALUE
              trent
              Hi,

              From just skimming over your reply, I think the issue is:
              Name: Set_Upduser
              Sequence: 10 (it’s the only DA)
              Event: Change
              Select Type: jQuery Selector
              jQuery Selector: input[name=”f03_NOSUBMIT”] 
              --note: the event does not fire if I use f03 
              --since that value is not actually
              --changed until submit with this
              --method.
              Condition: - No condition –
              True Actions:
              Sequence: 10
              Action: Set Value
              Fire When Event Result is: True
              Fire On page Load: Unchecked
              Stop Execution On Error: Checked
              Set Type: JavaScript Expression
              JavaScript Expression: 
              var row = $x_UpTill(this.triggeringElement, 'TR');
              var otherElement = $('input[name="f04"]',row)[0];
              otherElement.value = '&APP_USER.';
              Selection type: jQuery Selector
              jQuery Selector: input[name="f04"]
              The last two points - i dont think you need an additional selector at the end, as you are updating the value via Javascript code. That is likely why every row is getting updated.

              My download example hasn't been updated for sometime (i mean, download link).. let me do that now!... ok, that should be the latest one there - can you get it downloaded?? (Actually, I'm not sure if i have an installation script to create a table that page is based off.. ill have to check that later, but you should still be able to see the dynamic action code.)

              Regards,
              Trent

              Edited by: trent on Dec 28, 2011 2:26 PM
              • 4. Re: Dynamic Form in Tabular Form i.e SET VALUE
                amckinne
                Thanks Trent! The download works now. Of course my luck...I'm on Apex 4.0 - guess its time for me to upgrade (nothing like a little motivation :0} ).

                As to the jQuery selector in the "Affected Item" section. It is indeed the problem, unfortunately in 4.0 the field is required for the Set Value.
                When I changed the field to other selections, the DA works, but the submit then blows up. I just need to learn how to use these fields and selections. Any recommendations on "a picture is worth a thousand words" type documentation?

                In the meantime, I am building out An Apex 4.1 so I can run the import from your example. I'll update, when I figure out what the issue is with my DA. Hopefully others may find it helpful.

                Many, many thanks!
                • 5. Re: Dynamic Form in Tabular Form i.e SET VALUE
                  trent
                  No worries ;-)

                  I just tested it out on application express, and it seems to work fine, leaving the affected element unselected. Maybe you have selection type specified, just leave it blank (- Select Type -).

                  i.e.

                  http://i40.tinypic.com/vfz2hk.png
                  • 6. Re: Dynamic Form in Tabular Form i.e SET VALUE
                    amckinne
                    And the culprit was....(drum roll please)
                    "Action: Set Value"
                    I should have had it set to “Execute Javascript”.

                    When Set Value is selected for the Action, the "Affected Item" becomes a required field. Thus my conundrum on setting that particular field.

                    I changed the "Action" of the "True Action" to "Execute JavaScript" and voila! The DA now works like a charm!
                    Many Thanks again!
                    • 7. Re: Dynamic Form in Tabular Form i.e SET VALUE
                      Gaas
                      Thanks Trent,

                      It's a usefull help and working fine.

                      Can I use select query instaed of = 'somethingnew'

                      e.g:

                      otherElement.value = select "DEPT"."DNAME" as "DNAME"  from      "EMP" "EMP"+

                      where   "EMP"."DEPTNO"="DEPT"."DEPTNO"+

                      Thanks in advance
                      • 8. Re: Dynamic Form in Tabular Form i.e SET VALUE
                        trent
                        Hi,

                        You would need to create an on demand application process and use AJAX to get the value.

                        Regards,
                        Trent
                        • 9. Re: Dynamic Form in Tabular Form i.e SET VALUE
                          Snoesky
                          Hi,

                          I have the same requirements: setting a columns value based on another columns value in a tabular form.
                          The given example works fine except for new (added) rows.

                          In my application it i need column 2 to get a new value based on the value put in column 1. Even with a new row


                          Regards,

                          Joshua