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

JavaScript/Grid Calculator

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

    JavaScript/Grid Calculator

    Here is a simple calculator you can add to any web application or existing grid. You can even manually type (or edit) the calculation in the display and then press the = button to compute.

    You can move buttons around to suit your own taste and enhance the calculator with your own buttons to perform more advanced computations. To customize this calculator to your own application, look at the OnClick JavaScript code in the "Test" grid calculator "button" (it's actually an image w. code). You need to put that code in your own calling or parent grid.

    Note: If you want to separate the submit action from the "=" calculation action, take a look at the simple instructions in the = button's OnClick JS code.

    See attached image and download...
    Last edited by Peter.Greulich; 10-16-2010, 02:38 PM.
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: JavaScript/Grid Calculator

    Excellent! This works perfectly, other than me not being able to find the right parts of the code to change, to get the calculator results to go to the field, after clicking "=". I changed all instances of "TestGrid" to "NotesGrid" (Notes being the name of my grid). Any ideas as to what else I'm supposed to change?

    Thanks

    Comment


      #3
      Re: JavaScript/Grid Calculator

      Originally posted by Leonw43 View Post
      Any ideas as to what else I'm supposed to change?
      In the calling (parent) grid, change the button's (in my example I use an image, but it's really the same difference) OnClick event, change TestGrid to any name you want to use. It doesn't have to be the name of the grid. You can even leave it called TestGrid, if you want. It's just a variable pointer.
      Code:
      window['[COLOR=Blue][B]TestGrid[/B][/COLOR]'] = {grid.Object};
      rownum = {Grid.RowNumber};
      In the calculator's "=" button's OnClick event, the grid pointer variable name, must be the same as the name you used in the parent calling grid, in my case TestGrid. The field name that you are trying to populate must be in CAPITAL letters, in my case the actual field name is NUMBER. This must be the actual name of your field. The calculator grid itself has an unbound field called VALUE which you just leave alone. And I also use a JavaScript variable which I happened to name Value and which you can just leave as it is.
      Code:
      var [COLOR=Red][B]Value [/B][/COLOR]= {grid.Object}.getValue('G','VALUE','1');
      var [B][COLOR=Red]Value [/COLOR][/B]= eval(Value);
      
      {grid.Object}.setValue('G','VALUE','1',[B][COLOR="Red"]Value[/COLOR][/B]);
      window['[B][COLOR=Blue]TestGrid[/COLOR][/B]']._setValue('G','[B][COLOR="DarkRed"]NUMBER[/COLOR][/B]',rownum,[COLOR=Red][B]Value[/B][/COLOR]);
      I believe that's it.
      Last edited by Peter.Greulich; 10-22-2010, 12:56 PM.
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: JavaScript/Grid Calculator

        Thanks! I've done all of the following and made sure 100% that everything has been entered correctly, the calculator works but it still doesnt show in the field after clicking "=". I'm sure theres an option somewhere that has been set so that this doesnt work, but it's beyond me. If it makes any difference, it's a field in the detail view. Any ideas?
        Thanks,

        Leon

        Comment


          #5
          Re: JavaScript/Grid Calculator

          Originally posted by Leonw43 View Post
          If it makes any difference, it's a field in the detail view.
          {grid.Object}.setValue('D','VALUE','1',Value);

          G = Grid view
          D = Detail view
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: JavaScript/Grid Calculator

            Originally posted by Peter.Greulich View Post
            {grid.Object}.setValue('D','VALUE','1',Value);

            G = Grid view
            D = Detail view
            AH! Makes me want to go learn javascript properly myself :)

            Thanks, it works fine now.

            Comment


              #7
              Re: JavaScript/Grid Calculator

              Originally posted by Leonw43 View Post
              AH! Makes me want to go learn javascript properly myself :)

              Thanks, it works fine now.
              The {grid.Object}.setValue fucntion is actually an Alpha JS function. If you click on the JS event code and on "Insert Grid Method", there is a jiffy help section for each of the functions.
              Peter
              AlphaBase Solutions, LLC

              [email protected]
              https://www.alphabasesolutions.com


              Comment


                #8
                Re: JavaScript/Grid Calculator

                Ah thankyou, I do have a question though, since I want to use your calculator in multiple fields, would I have to make duplicates of the calculator component with the different field names in the code? Or is there an easier way?

                Comment


                  #9
                  Re: JavaScript/Grid Calculator

                  Originally posted by Leonw43 View Post
                  Ah thankyou, I do have a question though, since I want to use your calculator in multiple fields, would I have to make duplicates of the calculator component with the different field names in the code? Or is there an easier way?
                  No, you have to use a little JS to set some variables.

                  e.g. lets say Fields 1,2,3 all call the calculator. In the code before the calculator call put some JS like this for each field:

                  Field1: varField = 'FIELD1'
                  Field2: varField = 'FIELD2'
                  Field3: varField = 'FIELD3'

                  So each field is setting the "global" variable called varField a value the same as the field name in CAPITAL LETTERS.

                  Then in the last line of code in the calculators "=" button, you put this:

                  window['TestGrid']._setValue('G',varField,rownum,Value);
                  Peter
                  AlphaBase Solutions, LLC

                  [email protected]
                  https://www.alphabasesolutions.com


                  Comment


                    #10
                    Re: JavaScript/Grid Calculator

                    Hmm, it seems to pickup on the variables, however I'm having problems with using the calculator with "D" replacing "G". Do I replace all instances of G with D or is it just the one? I've tried many combinations of them and for some reason the calculator always gives a result of 1.
                    I also have a list of variables written in the "=" button before the calculator is called, but it only places the result into the last variable field! (the result being 1 all the time)
                    Any ideas as to where I've gone wrong?
                    Thanks

                    Comment


                      #11
                      Re: JavaScript/Grid Calculator

                      Originally posted by Leonw43 View Post
                      Hmm, it seems to pickup on the variables, however I'm having problems with using the calculator with "D" replacing "G". Do I replace all instances of G with D or is it just the one? I've tried many combinations of them and for some reason the calculator always gives a result of 1.
                      I also have a list of variables written in the "=" button before the calculator is called, but it only places the result into the last variable field! (the result being 1 all the time)
                      Any ideas as to where I've gone wrong?
                      Thanks
                      You will have to provide your code. I don't exactly follow you.

                      Use D if your fields are calling the calculator are in the detail section or of G if it is in the grid section.
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        Re: JavaScript/Grid Calculator

                        Ok here's what I've got:

                        var Value = {grid.Object}.getValue('D','VALUE','1');
                        var Value = eval(Value);

                        {grid.Object}.setValue('D','VALUE','1',Value);
                        window['Notes']._setValue('D',varField,rownum,Value);

                        As for the calculator button javascript, here is generally what I've done (for the '7' button):

                        var Value = {grid.Object}.getValue('G','VALUE','1');
                        Value = Value + 7;
                        {grid.Object}.setValue('G','VALUE','1',Value);
                        (tried setting this to "D" and it didnt work)

                        And last of all, the code for the fields themselves:

                        window['Notes'] = {grid.Object};
                        rownum = {Grid.RowNumber};

                        Hope this helps, thanks

                        Comment


                          #13
                          Re: JavaScript/Grid Calculator

                          Peter,
                          Looks good and I appreciate it.

                          Now tell me how to make this one work.

                          [URL="http://www.nogray.com/time_picker.php"]

                          Comment


                            #14
                            Re: JavaScript/Grid Calculator

                            @PeterG

                            Thank you so much!

                            I was doing some data entry, wished I had a calculator Pop-up, and installed yours -

                            The posts above seem to be talking about using the calculator multiple times, within one component.

                            I'll be wanting to use it in multiple components - so I'll probably be back with questions....

                            VERY VERY VERY satisfying...
                            MSQL since 2010
                            A5V11 since Feb 2012

                            Comment


                              #15
                              Re: JavaScript/Grid Calculator

                              Hi Peter -
                              I'm at the point where I'm integrating your calculator into a 2nd grid component and I'm having a bit of trouble defining the varField

                              Can you see where I'm going off-kilter?

                              Grid1.Image.Onclick.InlineJavacript
                              ExchangeRate: varField = 'EXCHANGERATE'
                              window['TestGrid'] = {grid.Object};
                              rownum = {Grid.RowNumber};


                              Grid2.image.Onclick.InlineJavacript
                              UnitPrice: varField = 'UNITPRICE'
                              window['TestGrid'] = {grid.Object};
                              rownum = {Grid.RowNumber};



                              Calculator.Button.5.OnClick
                              var Value = {grid.Object}.getValue('G','VALUE','1');
                              var Value = eval(Value);

                              {grid.Object}.setValue('G','VALUE','1',Value);
                              window['TestGrid']._setValue('G',varField,rownum,Value);



                              thank you -
                              MSQL since 2010
                              A5V11 since Feb 2012

                              Comment

                              Working...
                              X