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

How do I retreive a calculated value from a child grid

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

    How do I retreive a calculated value from a child grid

    I have a UX with a repeating section. In the repeating lines I have a button to open a grid where the user can add in purchases for that record.

    The expense grid includes a calculated total expense field. I need to return/pass this total field back to the repeating container line.

    How is this done?

    Jack

    #2
    Re: How do I retreive a calculated value from a child grid

    Hi Jack

    When you set up the button the calls the grid you need to give the grid an unique Alias.
    You can then get a pointer to the child (Grid)

    With the pointer you can then use methods GetValue you then want to use this to setValue.
    Because you are using the repeating section you need to pass in the rownumber, care this needs to be zerobased.

    You also need to decide what will trigger this.

    Michael

    Tomorrow I should be at my desk, reply if you want more details.

    Comment


      #3
      Re: How do I retreive a calculated value from a child grid

      Thanks Michael...I'll give it a go and get back if I can't get it working.

      Jack

      Comment


        #4
        Re: How do I retreive a calculated value from a child grid

        How do you capture the calling parent when going from a repeating row in a UX component to call a linked grid.

        Everything I try always get a "false" or blank id/name.

        Since I guessing this might be a common requirement, I must be missing the issue.

        My latest failed coding (in the grid, Client-Side onGridRender event) is:

        var myparent={grid.Object}.getParentObject();
        if (myparent) {
        alert(myparent)
        }
        else
        {
        alert('No parent object detected.');
        }

        Jack

        Comment


          #5
          Re: How do I retreive a calculated value from a child grid

          Hi

          I am not up to speed yet as I have just arrived in Hong Kong and I don't have Alpha on my laptop yet.

          Is your syntax correct? You are calling from a dialogue but using {grid.object} I cannot check this.
          Another thought is, is the grid the parent or child?
          If the UX was launched from the grid then the grid is the parent. If the UX calls the grid then the grid is the child.

          Michael

          Comment


            #6
            Re: How do I retreive a calculated value from a child grid

            Michael,

            I've tried using {grid.Ojbect} and {dialog.Object} both with negative results...does not see the parent.

            The grid is called from a button located in a repeating section of a UX component. The UX (or more correctly, the row in the repeating section) is calling the grid.

            I think the grid should be a child of the UX/repeating row in the UX.

            Jack

            Comment


              #7
              Re: How do I retreive a calculated value from a child grid

              Jack,

              You're opening a Grid, using Action Javascript I assume... you don't say... from a UX Repeating Section.

              You're right that the Grid is a Child of the UX.

              You really don't need to deal with the Repeating Section Active Row at the point of opening the Grid. You can get that when you're saving values back to the UX from the Grid.

              Once you're in your Grid... you're dealing only with the {Grid.Object} object... nothing else. (That's why any attempt to use {dialog.Object} will fail.)

              Your code should work... it works for me... except that you're trying to do an Alert on an Object... which doesn't really work.

              Your Calculated Total Expense field... is that per row? Or for the whole Grid... doesn't really matter... just curious.

              I assume you put your code into the onGridRender event just for testing... since it doesn't really help to have it there.

              You don't say what you're using to "invoke" setting the UX value from the Grid... a button? A Grid event? Again... doesn't really matter too much... just curious.

              This code should work for you... I've got this running from an Action Button I've added to the ToolBar of the Grid...

              Code:
              var pobj={grid.Object}.getParentObject();
              if (pobj) {
                   //alert('There is an object.');
                   var currentRow = pobj.getRepeatingSectionActiveRow('CONTAINER_1', true);
                   //alert(currentRow);
                   pobj.setValue('EXTENSION:'+currentRow,'44.44');
                   }
              else
              {
                   alert('No Object Detected.');
              }
              So... get the Parent of the Grid Object
              Now that you've got the dialog parent... you can execute dialog methods on that object.
              Go and get the current Active Row of your Repeating Section. Mine is named 'CONTAINER_1'.
              Now set a value (e.g. my UX control 'EXTENSION') with a value. Your value is going to be your calculated value.
              And... you're setting a Repeating Section control... so the syntax is controlName:rowNumber

              In your UX, have a look at the help for the function getRepeatingSectionActiveRow to understand the optional flag.

              Comment


                #8
                Re: How do I retreive a calculated value from a child grid

                Davik,

                Thanks...getting closer. Mine is working using a button on the grid also...

                Answers to your questions:

                1. In the UX repeating row, I'm using a button that calls an Action Javascript to "Open a Grid Component."

                2. I need to deal with the calculated total expense field...updates as individual grid records are updated. Each addition/deletion/change on a grid row could change the total expense calculation. (The grid is "linked" to the id in the UX repeating row...only those records in the Grid associated link are shown...not the entire grid.)

                3. OnGridRender was used to attempt to get the .getParentObject() code working...not as final use.

                4. I am looking for an "automatic" way to set the value in the UX repeating row equal to the calculated total expense field in the grid. I was thinking that once I had the code correct to add it to the grid Client-side events of "afterRowDelete" and "afterRowSubmit."

                Right now, I've added an action button to the grid's tool bar as you spoke of...it correctly copies the "44.44" back into the UX repeating row.

                How do you reference a "e" field in the javascript code. (I believe its the "e.summaryValue.EXPENSECOST.Total" field?)

                Comment


                  #9
                  Re: How do I retreive a calculated value from a child grid

                  How do you reference a "e" field in the javascript code. (I believe its the "e.summaryValue.EXPENSECOST.Total" field?)
                  Is that your Grid Calculated Field?

                  Comment


                    #10
                    Re: How do I retreive a calculated value from a child grid

                    Davidk,

                    Yes...the grid row has an "ExpenseCost" field that the user enters the actual cost of the item(s) they purchased.

                    That field has a calculated "total expense" field that is then updated/changed as the individual rows are updated.

                    I believe on the Server side, the codes reference the summary fields as "e.summaryValue.FIELDNAME.Total" or count or average, etc.

                    Jack

                    Comment


                      #11
                      Re: How do I retreive a calculated value from a child grid

                      Hi Jack

                      Just got up and just got Alpha working. You are lucky enough to have a reply from David. I am not going to add to this discussion as David is a master and I am just a student. Alpha keeps me informed of changes on the thread, if I can help I will.

                      The knowledge that I was trying to impart came from David; he is clear in his language and generous with his time.

                      Michael

                      Comment


                        #12
                        Re: How do I retreive a calculated value from a child grid

                        So... this gets a little complicated... and so that leads me to believe there's an easier way. That being said... here it is.

                        First... here's the challenge: You want to open a grid... from a UX... and change a value in a grid. Then, have a summary value in that grid recalculate... and pass that new summary value back to the UX.

                        Second... here's problem #1: The summary values in a grid do not recalculate unless the grid is refreshed. Not a row refresh... but a full grid refresh.
                        The full grid refresh poses a bit of a new problem... but we'll get to that.

                        Third... here's problem #2: We're trying to grab the summary value and send it back to the UX. We're doing this in Javascript on the client side... which is... faster than a speeding bullet. Meanwhile...we're waiting for the grid to update SQL tables, refresh, and recalc summary values all on the server side... which is always a step behind the client.

                        The solution is to ask the client to slow down a bit... let the server catch up.

                        In the Grid, Server-side event, onSummarySectionRender...

                        Code:
                        e.javascript = "{grid.Object}.__summaryTotal = " + e.summaryValues.TOTAL.Total + ";"
                        Here we are setting a variable in the grid object namespace which holds the value of our summary field.

                        In the button which updates the UX...

                        Code:
                        var pobj={grid.Object}.getParentObject();
                        if (pobj) {
                        
                        	var rowNum = {Grid.Object}._selectedRow;
                        	{grid.Object}.submitGridPart();
                        	
                        	setTimeout(function(){
                        	{grid.Object}.refresh();
                        
                        		setTimeout(function(){
                        			var currentRow = pobj.getRepeatingSectionActiveRow('CONTAINER_1', true);
                        			var summaryTotal = {grid.Object}.__summaryTotal;
                        			pobj.setValue('EXTENSION:'+currentRow,summaryTotal);
                        			{grid.Object}.setSelectedRow(rowNum);
                        			},500);
                        			
                        		},300);
                        	}
                        	else
                        	{
                        	alert('No Object Detected.');
                        	}
                        Here we are using 2 setTimeout functions. One to allow the submit to take effect... and one to allow the refresh to take effect.
                        The submit takes place... then the refresh takes place... now we have our current summary total which was placed into a grid object variable in that server-side event.
                        We grab that variable and send it over to the UX.

                        A new problem is that when we refresh the Grid the current record jumps to the top of the displayed page. So... we first grab that row... and then set the current record back in place after doing everything else. It's not the prettiest... but not too bad.

                        Now... all this is way too complex... it works... but it's not necessary. Kinda neat... but too much trouble.

                        So... in the morning I'll post a much cleaner solution using the same code, but just using the Server-side event. I think that will work.

                        Comment


                          #13
                          Re: How do I retreive a calculated value from a child grid

                          Davidk,

                          Updated my grid with your coding and it works as desired...but I don't understand your note on the total update issue.

                          I see that when I press the "update" button on the grid toolbar that we are refreshing the grid, but prior to this, when I change a value in the grid, either a new record/row or change the cost value in one of the existing rows, if I submit the change/update the total field shows the proper calculated amount.

                          Is this "built-in" to the grid and happening in the background, or is it a false sense of "working?"


                          Jack

                          Comment


                            #14
                            Re: How do I retreive a calculated value from a child grid

                            Michael,

                            It is amazing to me how much the user community knows about Alpha 5. I'm a bit of a thick skull at times and seem to be easily lost without some type of documentation to explain the intended working of the various pieces, components, tools, etc.

                            Once the solutions are found, it seems so easy. What a powerful program once you learn the "tricks."

                            Jack

                            Comment


                              #15
                              Re: How do I retreive a calculated value from a child grid

                              Originally posted by jackp_MDB View Post
                              Davidk,

                              Updated my grid with your coding and it works as desired...but I don't understand your note on the total update issue.

                              I see that when I press the "update" button on the grid toolbar that we are refreshing the grid, but prior to this, when I change a value in the grid, either a new record/row or change the cost value in one of the existing rows, if I submit the change/update the total field shows the proper calculated amount.

                              Is this "built-in" to the grid and happening in the background, or is it a false sense of "working?"


                              Jack
                              This may depend on your grid settings. In your Grid Update settings... in the property Row Refresh after Edits... what that's set to? Mine is set to <auto select> and my Summary values do not change after an edit. If set to Full-Page then the summary value updates because the grid is refreshed. What is the behaviour of your current row. When using the Grid Submit, when you submit a change, does the current row stay where it is?

                              Comment

                              Working...
                              X