1 2 Previous Next 16 Replies Latest reply: Feb 8, 2013 5:00 AM by Snoesky RSS

    Derived column?

    Snoesky
      Hi All,

      i'm using APEX 4.2.


      I have two tables: ORDERS(id, prod_id, quantity) and PRODUCT(id, name, price).

      I have created a tabular form page on ORDERS with a LOV to get the PRODUCT id and name.

      This is working fine.

      Now the tricky part (for me).

      I also want the row to display (no need to save in database) the PRODUCT price and the total price (= price * quantity).

      I want this to chance when i select a different PRODUCT or when i change the quantity.

      I thought it could be done with derived columns but i don't see any possibilities there.

      Please help.

      Regards,

      Joshua
        • 1. Re: Derived column?
          Mahmoud_Rabie
          Dear Snoesky,

          You can do it with Dynamic Actions.

          For example see this
          Re: How to calculate fields in a form?

          For Basics of Dynamic Actions
          http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r41/dynactions/dynactions.htm

          If the question is answered close it as answered and give the points where earned ..

          Regards
          Mahmoud
          • 2. Re: Derived column?
            Snoesky
            Thanks for your response.

            But a Dynamic Action won't work because i have a Tabular Form with report columns instead of items.


            Best regards,

            Joshua
            • 3. Re: Derived column?
              fac586
              Snoesky wrote:
              Thanks for your response.

              But a Dynamic Action won't work because i have a Tabular Form with report columns instead of items.
              Why won't a Dynamic Action work?
              • 4. Re: Derived column?
                Snoesky
                Quick reaction :-)

                The tabular form shows multiple rows. The data is shown in Report Columns. When i create a DA i have to specify an Event and a Selection Type. The Event will be "Change" and for the Selection Type i would like to refer to the Report Columns.
                But that is impossible. Only items can be selected.


                Best regards,

                Joshua
                • 5. Re: Derived column?
                  fac586
                  Snoesky wrote:
                  Quick reaction :-)

                  The tabular form shows multiple rows. The data is shown in Report Columns. When i create a DA i have to specify an Event and a Selection Type. The Event will be "Change" and for the Selection Type i would like to refer to the Report Columns.
                  But that is impossible. Only items can be selected.
                  Incorrect. Anything can be selected using a jQuery selector. For example, controls in a tabular form column: +{message:id=9204302}+
                  • 6. Re: Derived column?
                    Tom Petrus
                    It is not impossible. Understand that all items on a page, whether they are page items or items in a tabular form, are just html input elements. This means you can target each element with a jQuery selector. If the selector targets multiple elements (array) then binding an event to this collection would let each element in this collection trigger this event.
                    So when you target all input elements in a given column and bind an on-change event to them, it would work just like when you bind an on-change event to an item.
                    So when creatinga dynamic action you can choose 'jQuery Selector' instead of 'Item(s)' as triggering element. However, setting the value of another column on the same row will require javascript and not a set value action. Targetting columns in another column on the same has been discussed many times on the forum.
                    However, if you're not familiar with html/dom and even javascript, you've sure picked a solution that requires you to at least understand you know what you're doing. I'd not recommend just copying code over without understanding why it does what.
                    • 7. Re: Derived column?
                      Snoesky
                      Oke, i understand, but it doesn't seem to work for me.

                      Report Column: KTN_NAME

                      DA: TEST, Event double click, selection type Jquery and for the Selector i have looked at the html page source and found that KTN_NAME has id="fmap_004"

                      So do i use this? like #fmap_004

                      True Action: Alert "Help"


                      Now when i double click in de KTN_NAME column nothing happens.
                      • 8. Re: Derived column?
                        fac586
                        Snoesky wrote:
                        Oke, i understand, but it doesn't seem to work for me.

                        Report Column: KTN_NAME

                        DA: TEST, Event double click, selection type Jquery and for the Selector i have looked at the html page source and found that KTN_NAME has id="fmap_004"

                        So do i use this? like #fmap_004

                        True Action: Alert "Help"


                        Now when i double click in de KTN_NAME column nothing happens.
                        What does the KTN_NAME column contain?
                        • 9. Re: Derived column?
                          Snoesky
                          Just text. The name of the product. It is updateble.
                          • 10. Re: Derived column?
                            fac586
                            Snoesky wrote:
                            Just text. The name of the product. It is updateble.
                            In terms of HTML elements? "It is updateable" does not fit with my concept of "just text".
                            • 11. Re: Derived column?
                              Snoesky
                              <input type="hidden" name="fmap" value="KTN_NAME" id="fmap_004" />
                              • 12. Re: Derived column?
                                fac586
                                fac586 wrote:
                                Snoesky wrote:
                                Oke, i understand, but it doesn't seem to work for me.

                                Report Column: KTN_NAME

                                DA: TEST, Event double click, selection type Jquery and for the Selector i have looked at the html page source and found that KTN_NAME has id="fmap_004"

                                So do i use this? like #fmap_004

                                True Action: Alert "Help"
                                Event: Click

                                Selection Type: jQuery

                                Selector: <tt>td[headers="KTN_NAME"] input</tt>

                                Condition: No Condition

                                True Actions: Execute JavaScript Code
                                alert('Foo');
                                Uncheck Fire On Page Load

                                As Tom points out above, the real challenge is in getting the JS code executed to perform the necessary processing in the affected row...
                                • 13. Re: Derived column?
                                  Snoesky
                                  It works!!! Thanks a lot.


                                  But i still don't understand why #fmap_004 doesn't work.

                                  Edited by: Snoesky on 8-feb-2013 2:32
                                  • 14. Re: Derived column?
                                    Tom Petrus
                                    That is how jQuery selectors work. For example, the #-sign is an ID selector: http://api.jquery.com/id-selector/ . As the documentation says, this uses the javascript document.getElementById() function. Using "#fmap_004" would be targetting a single element with id "fmap_004", which is not what you want. The "fmap" items are also -not- the items which hold your values in the tabular form, they are a mapping generated by apex.

                                    You might do yourself a service and read up on some basic javascript principles, and then hop over to some jQuery stuff (such as selectors http://api.jquery.com/category/selectors/). Get some decent debugging tools, such as Firebug for Firefox, which allow you to easily inspect the html and dom, and debug and run javascript code efficiently.
                                    1 2 Previous Next