1 2 Previous Next 17 Replies Latest reply: Nov 28, 2013 3:41 AM by Madonna RSS

    Not able to perform computation on Non Database Column in Tabular Form

    Madonna

      Hi All,

       

                I have a Master and a Detail Tabular Form which has the following requirement:

       

      • If I choose Two Way in my Trip Type item in my Master form,the  No of Tickets field in my Detail Tabular form has to get doubled ie. 2*No of tickets
      • The No of Tickets is a Display as Text(does not save state) field so I am not able to select the value of the field in jquery.

       

      Kindle help me with this.

       

      Thanks and Regards,

      Madonna

        • 1. Re: Not able to perform computation on Non Database Column in Tabular Form
          B.Delmée

          How about something like the following (where ADHOC is your text column):

           

          function adhoc_double() {

            var iter = $('td[headers="ADHOC"]');

            for (var idx = 0; idx < iter.length; idx++) {

                var i = parseInt($(iter[idx]).text());

                if (! isNaN(i)) $(iter[idx]).text(2*i);

            }

          }

          Include this in the "javascript" section of your page properties, then hook it up  as a dynamic action when your "round trip" select list changes value.

          • 2. Re: Not able to perform computation on Non Database Column in Tabular Form
            Nicolette

            Madonna

             

            Madonna wrote:

            The No of Tickets is a Display as Text(does not save state) field so I am not able to select the value of the field in jquery.

             

            So you don't want a computation that works server site but a dynamic action that works client side.

             

            Of course you can get to the "values" of the No of Tickets column just not using an id or name attribute.

            Most report templates use a headers attribute in the TD element.

            And since it is a display only field you have to change the innerHTML instead of the value.

             

            Since getting the right selector for the No of Tickets seems to be the problem. And the selector is dependable on your report templates and column aliases etc., it is best to use apex.oracle.com to show what you have so far so we can help you further.

             

            Nicolette

            • 3. Re: Not able to perform computation on Non Database Column in Tabular Form
              Madonna

              Hi Nicolette,

               

                        Can I have your personal mail ID where I can send my application and credential details on apex.oracle.com?

               

              Thanks and Regards,

              Madonna

              • 4. Re: Not able to perform computation on Non Database Column in Tabular Form
                Nicolette

                Madonna

                 

                Please make a quest developer account and post the login details here.

                You can always close the account when the question is answered.

                 

                Don't forget the workspace name when you post the login details.

                 

                Nicolette

                • 5. Re: Not able to perform computation on Non Database Column in Tabular Form
                  Nicolette

                  Madonna

                  I have added a true and a false action to the dynamic action disable.

                   

                  Here is the code of the false action. The action type is Execute JavaScript Code

                  /*Select all input elements with the name attribute f14*/
                  apex.jQuery('[name="f14"]').each(
                    function(){
                      var lNoTickets,lSpan;
                      /*Calculate the number of tickets by getting the value and times 2*/
                      lNoTickets =(this.value*2);
                      /*Determine the display element*/
                      lSpan = this.nextSibling.nextSibling;
                      /*Set the new number of tickets to the display element*/
                      apex.item(lSpan.id).setValue(lNoTickets);
                       /*Set the new number of tickets to the hidden element*/
                      this.value = lNoTickets;
                    }
                  )
                  

                  Because you have used "Display as text(saves state)" apex renders both an input item of type hidden. And a span element that displays the value.

                  Both these elements need to be set separately. See the last two lines of the code.

                  The calculation of the new Number of tickets happens for each hidden element with the name f14.

                  And the span element is the second sibling of the hidden element.

                   

                  Adding a user to your workspace.

                  Go to Administration > Manage Users and Groups > Create User.

                  Than you don't have to share your own login credentials any more.

                   

                  Nicolette

                  • 6. Re: Not able to perform computation on Non Database Column in Tabular Form
                    Madonna

                    Hi Nicolette,

                     

                              Thanks for the help but my requirement is not what you have done.

                    I need the No of tickets to not be saved in the database and more over if you see the Region source of the tabular form , I have got the value for the No of tickets using an inline query.

                    This value is displayed once after the after the page is submitted i.e either after creation or updation.

                    So for One Way Trip type  the value populates correctly in the No of tickets after the page is submitted but for Two-Way the value must be 2 times the value that comes for One Way.

                    I do not need this value to be saved in the database and that's why I have used Display as text(does not save state).

                     

                    So Please can you help me how to proceed with this?

                    you can use my login credentials itself for now if you still have.

                     

                     

                    Thanks and regards,

                    Madonna

                    • 7. Re: Not able to perform computation on Non Database Column in Tabular Form
                      Nicolette

                      Madonna

                       

                      And that is way you're test application on apex.oracle.com should be exactly as you want it.

                      The display type of the ATTRIBUTE_1 column is Display as text(saves state) this is not what you claim it to be.

                      I didn't change the display type of the ATTRIBUTE_1  column.

                      I only added the 2 "Execute javascript code" actions and worked with the display types you have used.

                       

                      Nicolette

                      • 8. Re: Not able to perform computation on Non Database Column in Tabular Form
                        Madonna

                        Hi Nicolette,

                         

                                  oops, I am sorry it has to be Display as Text(does not save state).

                        Can you change it and help me out please?

                         

                        Thanks and Regards,

                        Madonna

                        • 9. Re: Not able to perform computation on Non Database Column in Tabular Form
                          Nicolette

                          Madonna

                           

                          I have changed the display type and the javascript code of the true action.

                          I have left the false action for you.

                           

                          The new code is.

                          apex.jQuery('[headers="No of Tickets"]').each(
                            function(index){
                              var lNoTickets,lElement = this;
                              /*Get the number of tickets*/
                              lNoTickets = lElement.innerHTML;
                              /*Calculate the new number*/
                              lNoTickets = lNoTickets/2;
                              /*Display the new value*/
                              lElement.innerHTML = lNoTickets;
                          });
                          

                          The use of the local variables is mainly for educational and debug purposes.

                          The getting, calculation and setting could all be done in 1 line of code.

                           

                          Nicolette

                          • 10. Re: Not able to perform computation on Non Database Column in Tabular Form
                            Madonna

                            Hi Nicolette,

                                      I have set up my updated sample application in apex.oracle.com

                            Below are the login credentials:

                            Workspace: XXAPEXTEST

                            User:PUBLIC

                            Password:PUBLIC

                             

                            My Application Details:

                            Travel Management System

                            33533 Database Application

                             

                            Right now I have removed the dynamic action.

                            Can you check how my application works and add them in the right way and help me out?

                             

                            Thanks and regards,

                            Madonna

                            • 11. Re: Not able to perform computation on Non Database Column in Tabular Form
                              Nicolette

                              Madonna

                               

                              What is wrong with the code I provided in the application TEST2-Travel Management System CDOT ?

                               

                              Did you try to implement it yourself?

                              When you debug the javascript does it run the anonymous function?

                               

                              It starting to sound like you want me to do your job.

                               

                              Nicolette

                              • 12. Re: Not able to perform computation on Non Database Column in Tabular Form
                                Madonna

                                Hi Nicolette ,

                                 

                                Sorry you have understood me wrong, I tried that code and it didn't work the way I required & I am not making you do my job.

                                Every time I tried to change one way to two way or vice versa the value was becoming half of the current value.

                                 

                                The way I require it is :

                                When I choose One Way in the Master level and for instance if its going to be Alone in Accompany type then the No of tickets must be 1

                                or if the user requires his family too then if he is adding 3 members in his family then the No of tickets will be 4.

                                 

                                The above scenario works fine for One way , but for Two Way and for the same above scenario I require the No of tockets to be 1*2=2*(if accompany type is set as alone) or 4*2=8(if the user has included his family members too)


                                Thanks and regards,

                                Madonna

                                • 13. Re: Not able to perform computation on Non Database Column in Tabular Form
                                  Nicolette

                                  Madonna

                                   

                                  Did you even read and tried to understand the code I have given you.

                                   

                                  Because how hard is it to copy the code from the true action to the false action.

                                  And change the calculation from divided by 2 to times 2.

                                   

                                  I have even added a comments in the code explaining what each line is doing.

                                  Form those comments it should be clear which code line does the actual calculation.

                                   

                                  Do you understand what I mean by a true action an the false action?

                                   

                                  Nicolette

                                  • 14. Re: Not able to perform computation on Non Database Column in Tabular Form
                                    Madonna

                                    Hi Nicolette,

                                     

                                                      I tried the false action too with *2 and I understood the code.

                                    I know what is true and false action.

                                     

                                    Regards,

                                    Madonna

                                    1 2 Previous Next