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

UX - Repaeting section Field Calculation

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

    UX - Repaeting section Field Calculation

    Hello

    I have a UX that has a date field and a person's Weight in KG (Numeric)

    E.g.

    Date 01/01/2013, Weight 84 KG

    I was wondering if there is a way to add a new field to calculate the Weight difference from one Repeating Row to the next in UX Repeating section?
    E.g.
    Repeating Section
    Date 01/01/2013, Weight 84 Difference = Nil - 0kg
    Date 01/02/2013, Weight 82 Difference = Loss - 2kg
    Date 01/03/2013, Weight 83 Difference = Gain - 1kg
    Etc:

    Any suggestions?

    Regards

    Ricky

    #2
    Re: UX - Repaeting section Field Calculation

    When I first read this I thought... interesting... then I thought... hold on a sec... then I thought... I remember writing something like this... that will be handy... so I did a search here (took less than one minute) and found this...

    http://msgboard.alphasoftware.com/al...ghlight=weight

    EDIT: Then I read again... and you need this for a UX... I should learn to read better.

    I think this could be easily adapted... I'll have a look.
    Last edited by Davidk; 12-28-2013, 07:03 PM.

    Comment


      #3
      Re: UX - Repaeting section Field Calculation

      With a few minor "dialog" specific changes... essentially it's the same code and process. There is a difference between physical rows and logical rows in a dialog. Physical rows include deleted rows... so watch out for that.
      Have a look at the documentation for {dialog.Object}.getRepeatingSectionActiveRow for more info on physical and logical and decide if you need to include the logical flag in the method.

      I put this code into the onChange event of the Weight field.

      Code:
      var currRow = {dialog.Object}.getRepeatingSectionActiveRow('CONTAINER_1');
      var diffW = 0;
      var prevRow = 0;
      var wChg = '';
      prevRow = currRow-1;
         
      if (prevRow > 0)
      {
      
         var prevW = {dialog.object}.getValue('WEIGHT:'+prevRow);
         var currW = {dialog.object}.getValue('WEIGHT:'+currRow);
         diffW = currW - prevW;
         diffW = diffW.toFixed(2);
         if (currW < prevW)
         	  {
            wChg = 'Loss';
            }
         if (currW === prevW)
            {
            wChg = 'No Change';
            }
         if (currW > prevW)
            {
            wChg = 'Gain';
            }
      
      	{dialog.object}.setValue('WEIGHTDIFF:'+currRow,diffW);
      	{dialog.object}.setValue('WEIGHTCHG:'+currRow,wChg);
      	
      }

      Comment


        #4
        Re: UX - Repaeting section Field Calculation

        hello

        take a look at this
        http://screencast.com/t/3d8AebUY

        not difficult.
        here is the code that fires onchange event of the weight

        Code:
        function calculateWeight as c (e as p)
        	
        	'debug(1)
        	dim current_row as n
        	dim last_row as n
        	dim current_wt as n
        	dim last_wt as n
        	dim differenceWt as n
        	current_row = e._repeatingSections.CONTAINER_1.activeRow
        	if current_row = 1
        		last_row = current_row
        		else
        		last_row = current_row - 1
        		end if
        	current_wt = e.dataSubmitted.weight[current_row]
        	last_wt = e.dataSubmitted.weight[last_row]
        	differenceWt = current_wt - last_wt
        	e._set.difference.value = differenceWt
        Last edited by GGandhi; 12-28-2013, 09:15 PM.
        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


          #5
          Re: UX - Repaeting section Field Calculation

          I have added the description you specified in the post #1

          http://screencast.com/t/vjZb8MtGV

          here is the modified code.

          Code:
          function calculateWeight as c (e as p)
          	
          	'debug(1)
          	dim current_row as n
          	dim last_row as n
          	dim current_wt as n
          	dim last_wt as n
          	dim differenceWt as n
          	dim difference as c
          	current_row = e._repeatingSections.CONTAINER_1.activeRow
          	if current_row = 1
          		last_row = current_row
          		else
          		last_row = current_row - 1
          		end if
          	current_wt = e.dataSubmitted.weight[current_row]
          	last_wt = e.dataSubmitted.weight[last_row]
          	differenceWt = current_wt - last_wt
          	
          	select
          		case (differenceWt = 0)
          			if current_row = 1
          		 	difference = "Base Start Weight"+" "+current_wt
          		 	else
          		 	difference = "No change from last visit"
          		 	end if
          		case (differenceWt < 1)
          			difference = "Lost"+" "+abs(differenceWt)+" "+"pounds from last visit"
          		case (differenceWt > 1)
          			difference = "Gained"+" "+abs(differenceWt)+" "+"pounds from last visit"
          	end select
          Last edited by GGandhi; 12-29-2013, 11:20 AM. Reason: modified the first row statment
          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


            #6
            Re: UX - Repaeting section Field Calculation

            Thanks for the reply guys,

            Thanks Govindan for the suggestions, will give it a try in the next few week, once holidays are over...

            Thanks David, I guessed the code would be different, in the UX than in a grid. That's why I re-post the initial request.

            Cheers.

            Comment


              #7
              Re: UX - Repaeting section Field Calculation

              Hello Gandhi,

              I have tried to use your code as shown above, but I must be doing something wrong as I cant seem to get it to work.

              I placed the code in the onchange event for Weight field. (But little unsure - if the code goes into the "text" section or the "server side xbasic" section?

              Also What fields in the repeating section must be added I have the following - eg: Weight, differenceWt, difference.

              Hope this make sense?

              any ideas?

              Comment


                #8
                Re: UX - Repaeting section Field Calculation

                I think Gandhi's solution is excellent. I would like to point out something. Each time you call an xbasic routine you're making a round trip to the server. If you need to go get something you haven't got then that's all ok. But... if you've already got everything you need at the client end, then there's no reason to go anywhere. I think this is important generally... and even more so when we're all looking at mobile (possibly disconnected) applications.
                Just something to keep in mind.

                Comment


                  #9
                  Re: UX - Repaeting section Field Calculation

                  create an ajax callback on onchange event, call that function calculateWeight
                  and add the code below the function declaration.

                  Code:
                  function calculateWeight as c (e as p)
                  	
                  	'debug(1)
                  	dim current_row as n
                  	dim last_row as n
                  	dim current_wt as n
                  	dim last_wt as n
                  	dim differenceWt as n
                  	dim difference as c
                  	current_row = e._repeatingSections.CONTAINER_1.activeRow
                  	if current_row = 1
                  		last_row = current_row
                  		else
                  		last_row = current_row - 1
                  		end if
                  	current_wt = e.dataSubmitted.weight[current_row]
                  	last_wt = e.dataSubmitted.weight[last_row]
                  	differenceWt = current_wt - last_wt
                  	
                  	select
                  		case (differenceWt = 0)
                  			if current_row = 1
                  		 	difference = "Base Start Weight"+" "+current_wt
                  		 	else
                  		 	difference = "No change from last visit"
                  		 	end if
                  		case (differenceWt < 1)
                  			difference = "Lost"+" "+abs(differenceWt)+" "+"pounds from last visit"
                  		case (differenceWt > 1)
                  			difference = "Gained"+" "+abs(differenceWt)+" "+"pounds from last visit"
                  	end select
                  
                    e._set.differenceWt.value = differenceWt
                    e._set.difference.value = difference
                  you don't need to show differenceWt you can hide it if you want or eliminate it altogether.

                  http://screencast.com/t/DWS0BV9YiS
                  Last edited by GGandhi; 12-31-2013, 07: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


                    #10
                    Re: UX - Repaeting section Field Calculation

                    Originally posted by Davidk View Post
                    I think Gandhi's solution is excellent.
                    thank you very much for your kind words, david. it is real honor.
                    thank you once again.
                    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


                      #11
                      Re: UX - Repaeting section Field Calculation

                      Me as well.
                      Insanity: doing the same thing over and over again and expecting different results.
                      Albert Einstein, (attributed)
                      US (German-born) physicist (1879 - 1955)

                      Comment

                      Working...
                      X