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



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

Adding up money - onGridRowCheck

  • Filter
  • Time
  • Show
Clear All
new posts

    Re: Adding up money - onGridRowCheck

    Originally posted by CharlesParker View Post
    looks like
    amt2 = amt.substring(1);

    should've read
    amt2 = amt2.substring(1);
    in your code...
    i changed it.
    and here is a screencast.
    thanks for reading


    version 11 3381 - 4096
    mysql backend
    [email protected]
    Skype:[email protected]
    1 914 924 5171


      Re: Adding up money - onGridRowCheck

      when i run the code as it was shown by selwyn, followed by you it looks like it is single page based.
      my be your final solution is the way to go.
      good luck in the meantime.
      thanks for reading


      version 11 3381 - 4096
      mysql backend
      [email protected]
      Skype:[email protected]
      1 914 924 5171


        Re: Adding up money - onGridRowCheck

        You both need to understand the nature of Javacsript... and parseFloat.

        If you parseFloat "$1,234.00" you get NaN
        If you parseFloat "1,234.00" you get 1
        If you parseFloat "1234.44" you get a number 1234.44

        You need to get rid of all the non-numeric characters.

        Further, your original code doesn't really make sense to me...

        ele2 = $('{grid.componentname}.V.R' + i + '.GRAND_TOTAL')
        ele3 = $('{grid.componentname}.V.R' + i + '.REMAINING_BALANCE')
        total = total + parseFloat($gvs(ele2));
        total2 = total2 + parseFloat($gvs(ele3));
        Here you're missing ; and you're using $gvs on an element that doesn't have a value. You'd be better off using .getValue() or at least doing this...

        ele2 = $('{grid.componentname}.V.R' + i + '.GRAND_TOTAL').innerHTML;
        Regardless... you always get back a string... and to use parseFloat you have to clean it up.
        Last edited by Davidk; 02-11-2017, 10:33 PM.


          Re: Adding up money - onGridRowCheck

          that is correct. parseFloat looks for number only in the data, all non numerical characters will render NaN or truncate. i paid attention to the $ sign only, error on my part.
          the display format is server side formatting. so the data is converted on the server and sent to the browser. i am wondering if the same thing is done in the client side, then the data will not change and will be still available as the original value but visually appears to the client as formatted to the dollar value so when you click on the row the non-formatted data will be available, making it easy to do the calculation.
          Last edited by GGandhi; 02-12-2017, 07:04 AM.
          thanks for reading


          version 11 3381 - 4096
          mysql backend

          [email protected]
          Skype:[email protected]
          1 914 924 5171


            Re: Adding up money - onGridRowCheck

            It was late last night that I quit. I started over fresh this morning and this is the final (working!) code as per david's method.
            if(e.checkboxValue == true){
            	var index = {grid.Object}.__selectedRows.indexOf(e.rowNumber);
            var custAmt = 0;
            var totAmt = 0;
            var fld1Amt='';
            var fld2Amt='';
            var new1Amt='';
            var new2Amt='';
            	fld1Amt = {grid.Object}.getValue('G','GRAND_TOTAL',{grid.Object}.__selectedRows[i]);
            	new1Amt = fld1Amt.replace(/[^0-9.]/g, "");
            	custAmt = custAmt + parseFloat(new1Amt);
            	fld2Amt = {grid.Object}.getValue('G','REMAINING_BALANCE',{grid.Object}.__selectedRows[i]);
            	new2Amt = fld2Amt.replace(/[^0-9.]/g, "");
            	totAmt = totAmt + parseFloat(new2Amt);
            formatCustAmt = custAmt.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
            formatTotAmt = totAmt.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
            $svs('total','$ ' + formatCustAmt);
            $svs('total2','$ ' + formatTotAmt);
            I got a pretty good understanding of it now as I went through each line learning wth it all means. As far as the lack of the ; symbol at the end of the lines of code, it worked without them and the use of $gvs is all direct from the checkbox select video from Alpha - you gotta learn from sonewhere right?
            Last night I had mixed up some of the var names and found that when I went into chromes dev tools this morning and finally got it to work as expected.
            SO - to sum it up, I learned about parseFloat and toFixed a bit, still have no Real understanding of the replace code but I do get that its stripping out the string from the number then putting it back in later based on the number of digits (looks like?)
            Thanks again to both of you for taking the time to help me sort it!

            Now I can go into my existing invoices, search by species and a date range THEN using the check box selector quickly see how much money I made and am owed.
            Yes, I couldve run a report but this is already built and available to me plus the default setting is to load the invoices marked as not paid so you can see who owes and how much etc. This is a screenshot of a ficticious account I use for free testing of my software. If anyone wants to login and check it out go to and use [email protected] for the login and qazwsx as the password.

            NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


              Re: Adding up money - onGridRowCheck

              After further testing I have come to the conclusion that my original code with part of Ghandi's code and part of Davids is actually the most reliable. Ghandis code presented an issue with any value that would include a comma, such as $4,750.00 as substring was only removing the dollar sign and parsefloat would round just as david said.
              David's code would run and then the component would freeze, and if I did a Quick Search and then did a checkbox select nothign would add or it would freeze so it was very buggy and not exactly sure why...I do beleive it was the way the array was initialized or setup but at this point all I know is that there were multiple issues with the component freezing SO
              as I said I combined them this morning and I beleive for my component this is the best solution - testing shows it works reliably and does not freeze.

              var ele = 0;
              var total = 0;
              var total2 = 0;
              var ele2 = 0;
              var ele3 = 0;
              var amt1 = 0;
              var amt2 = 0;
              for(var i = 1; i <= {grid.object}._rowsInGrid; i++) {
                  ele = $('{grid.componentname}.V.R' + i + '.__ROWCHECKBOX');
                  if( $gvs(ele) != '') {
                      ele2 = $('{grid.componentname}.V.R' + i + '.GRAND_TOTAL');
              amt1 = $gvs(ele2);
              amt1 = amt1.replace(/[^0-9.]/g, "");
              total = total + parseFloat(amt1);
                      ele3 = $('{grid.componentname}.V.R' + i + '.REMAINING_BALANCE');
              amt2 = $gvs(ele3);
              amt2 = amt2.replace(/[^0-9.]/g, "");
                         total2 = total2 + parseFloat(amt2);
              total = total.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
              total2 = total2.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");

              So as you can see I used Davids code to strip and later replace the $ sign and the comma while keeping the original code provided by alpha when using the checkbox selector along with ghandis suggestions. SO if anyone is following along - this works perfectly now. It goes in the OnGridRowCheck client side event. Thanks again guys, I couldn't have done it without your suggestions for sure!
              NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"


                Re: Adding up money - onGridRowCheck

                while this is excellent for coding, you could actually do this using the onSummaryRender event on the serverside events, and show the results above the grid.
                only disadvantage is that that will not update on rowcheck event it will need a button in the toolbar to activate that, the advantage is less coding and less playing with the javascript stripping and redressing the currency and works in multiple pages of data.
                and lastly i do not know the code you have will work when you move away from one page to the next, worth testing that out.
                regardless, if you are happy that is what matters.
                well done.
                thanks for reading


                version 11 3381 - 4096
                mysql backend
                [email protected]
                Skype:[email protected]
                1 914 924 5171


                  Re: Adding up money - onGridRowCheck

                  The code does not work with multiple pages (sort of) when doing the math as it zeros OUT when navigating to the next page even though the option of multiple pages is on for the checkbox selector, navigating to the next page you can then select the additional record and click the FILTER SELECTED button then you will have only those two records (or whatever you checked) from multiple pages and THEN you can then add up the columns and display the totals even though those two records (or more) were in multiple pages - so YES it works once you have your selection of records on the same page...and yes this will do for my needs quite well!
                  NWCOPRO: Nuisance Wildlife Control Software My Application: "Without forgetting, we would have no memory at what was I saying?"