Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Client side conditional calculation in a grid

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Client side conditional calculation in a grid

    Hi,

    Can anyone help me with the following:

    This is a grid with 4 fields - based on a SQL table.

    Posible field values are:
    field1= 'A' or 'B'
    field2 = from 1 to 1000
    field3= from 1 to 1000
    field4 = conditional result

    My question is how to calculate field4. The results required are:
    if field1='A' then field4=field2*field3
    if field1='B' then field4 = allow the user to enter the content of the field manually

    Can I do this?

    Thanks,
    Javier

    #2
    Re: Client side conditional calculation in a grid

    If there are only 2 possible values you can check for A. There is a calculated field control.

    Calc Field.png

    In my example I say if field1 is "A"
    then Field2xfield3 else 0

    I hope this helps

    Michael

    Comment


      #3
      Re: Client side conditional calculation in a grid

      Thanks Michael.
      Sorry but perhaps it was not clear what I�m looking for.
      What I would like to get is either the calculation or the possibility for the user to manually enter a value in field 4. If I use your suggestion the result is either the calculation or 0.
      Any ideas?
      Cheers,
      Javier

      Comment


        #4
        Re: Client side conditional calculation in a grid

        Hi Javier

        Can you explain the process. I think you need to "trap" this at point of data entry. How is the person updating the record?
        Can it be done via a UX component.

        Michael

        Comment


          #5
          Re: Client side conditional calculation in a grid

          In field On Change event of field1

          var d = {grid.Object}.getValue('G','FIELD1',-1);

          if (d == "B")

          {

          alert(" Please fill in field4");

          }

          Michael

          Comment


            #6
            Re: Client side conditional calculation in a grid

            Hi,
            The image below shows the grid layout. The "tipo" column dictates the type of transaction to be included.
            When you buy a stock, then the total trade is = "Cantidad" * "Precio" and this info goes under the column "PTRLOCALAMT"
            But when the "tipo" is a dividend or "DV+", then the user should leave "Cantidad" and "Precio" at 0, and include a value in "PTRLOCALAMT" which is = to the dividend received. In this case, the calculation "Cantidad" * "Precio" in the "PTRLOCALAMT" column should not be active to allow the user entering the dividend.

            I will try your sugestion from the previous post and comment on it. Thanks!

            Captura.JPG

            Comment


              #7
              Re: Client side conditional calculation in a grid

              Remember you can enable and disable controls.

              The javascript I returned if the easiest way to fill in "A" or remind on "B".

              For more complex logic flows you could call a dialog as the data entry form and then show hide sections.

              Michael

              Comment


                #8
                Re: Client side conditional calculation in a grid

                you should be able to do this with inline Javascript via onChange event than the calculated expression, I am sure.
                on top my head, not testing, this is what should be on the javascript.
                Code:
                var rowNum = {grid.rowNumber};
                var tipo = {grid.object}.getValue('G','TIPO',rowNum);
                var cantidad = {grid.object}.getValue('G','CANTIDAD',rowNum);
                var precio = {grid.object}.getValue('G','PRECIO',rowNum);
                if (tipo == "BUY") {
                var pirLocalAmt = cantidad * precio;
                {grid.object}.setValue('G','PIRLOCALAMT',rowNum,pirLocalAmt);
                }
                I can test it and show if you are not able to check this.

                edit:
                tested and is good
                take a look at this:
                http://screencast.com/t/MJ2Q94MvX
                Last edited by GGandhi; 06-23-2014, 05:43 AM.
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment


                  #9
                  Re: Client side conditional calculation in a grid

                  Gandhi/Javier

                  I think the field needs to be set to a label; update it automatically as Gandhi suggests, but pop up a UX with help for other options. That way Gandhi's calculation cannot be overwritten. The user has to have access in the other 2 situations.

                  Michael

                  Comment


                    #10
                    Re: Client side conditional calculation in a grid

                    Looking at it again you are better to popup a ux on change of tipo
                    That way you can show hide the fields you want to use.

                    One option is to show "Cantidad" and "Precio" when Tipo = Buy
                    option 2 is not to show "Cantidad" and "Precio" but rather to get the user to input "PTRLOCALAMT"

                    This way the user always expect a dialog but the fields "Change" based upon the drop down.

                    Michael

                    Comment


                      #11
                      Re: Client side conditional calculation in a grid

                      Sorry but if you prefer you can enable disable the fields in your grid based upon tipo.

                      Comment


                        #12
                        Re: Client side conditional calculation in a grid

                        You can have 2 field4", call them field4_a and field4_b.

                        1. Show/hide these based on the value from field1.
                        2. click the hide column or hide row checkbox for field4_b
                        3. use the free form layout of field4_a - put both field4_a and field_b in there side by side
                        4. now defijbe the 2 field4's the way you described, the first will be calculated, teh second will be user editable
                        oila!
                        Gary S. Traub, Ph.D.

                        Comment


                          #13
                          Re: Client side conditional calculation in a grid

                          Gary that works great but he also needs to do the same to field 5,2,3.

                          The logic dictates buy or sell value I think.

                          Michael

                          Comment


                            #14
                            Re: Client side conditional calculation in a grid

                            my view is the grid should not used to enter data, only to view the data
                            the data should be entered via a dialog or ux whatever the current name is. then the read only grid is updated.
                            the calculations need not be shown to the user at all so they won't be able to change play with that.
                            any adjustment should again take place via another entry.
                            in an accounting world the time marches on, never can go back and erase the past. keep the audit trail easy.
                            (incidentally this is what I said in the screencast, I showed the example to answer the question he posted)
                            thanks for reading

                            gandhi

                            version 11 3381 - 4096
                            mysql backend
                            http://www.alphawebprogramming.blogspot.com
                            [email protected]
                            Skype:[email protected]
                            1 914 924 5171

                            Comment


                              #15
                              Re: Client side conditional calculation in a grid

                              Hi Guys,
                              Many thanks for your contributions. Unfortuntely I have to wait until the weekend to test all these ideas. But I really appreciate your help.
                              Thanks gain.
                              All the best,
                              Javier

                              Comment

                              Working...
                              X