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

Get and Set Values from a child grid to parent grid

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

    Get and Set Values from a child grid to parent grid

    I have a grid that has a button that opens another (target) grid that I use to lookup values, make and save edits.
    The two grids are linked and filtered so that only the current record is opened in the target grid.
    I use the following to lookup values in the target grid and set values back into the parent grid.

    //Get a pointer to the parent component object that opened this grid.
    var po = {grid.Object}.getParentObject();

    //Get the values from the grid (you can define as many as you like)
    var firstname = {grid.object}.getValue('G','first_name',{grid.rowNumber}); //golfer table
    var lastname = {grid.object}.getValue('G','last_name',{grid.rowNumber}); //golfer table
    var city = {grid.object}.getValue('G','city',{grid.rowNumber}); //golfer table
    var cellphone = {grid.object}.getValue('G','last_name',{grid.rowNumber}); //golfer table
    var notify = {grid.object}.getValue('G','notify',{grid.rowNumber}); //golfer table


    //If this Grid does not have a parent then 'po' will be false.
    if (po) {
    po.setValue('first_name',firstname); //golfer table
    po.setValue('last_name',lastname); //golfer table
    po.setValue('city',city); //golfer table
    po.setValue('cellphone',cellphone); //golfer table
    po.setValue('notify',notify); //golfer table
    }

    //Close the grid.
    {grid.Object}.closeContainerWindow(this);

    Works perfectly!

    When I add another field from the golfer

    #2
    Re: Get and Set Values from a child grid to parent grid

    Originally posted by twwtc View Post
    Works perfectly!
    Great!
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant​​

    Comment


      #3
      Re: Get and Set Values from a child grid to parent grid

      Sorry ...... the last part of my post did not survive the copy and paste!

      My problem is that I have tried to add a field to the "get value" and "set value" into the parent grid, but from a different table than the other fields.
      I tried adding the following:

      var Handicap = {grid.object}.getValue('G','HANDICAP',{grid.rowNumber});

      po.setValue('HANDICAP',Handicap);


      HANDICAP is a field in the parent grid, but is from a different table than the other fields "set" in the previous post.

      Is this possible and/or can anyone see what I'm doing wrong?
      Thanks
      Tony

      Comment


        #4
        Re: Get and Set Values from a child grid to parent grid

        You set value isn't working because you are missing some important parameters (like which row are you setting).

        Here is some sample code I copied from Alpha's documentation. I think it'll be of help...

        Code:
        //Set value in 'LASTNAME' field from the Grid part, row 4. Note that field name must be uppercase.
        {grid.object}.setValue('G','LASTNAME',4,'Smith');
        
        //Set value in 'LASTNAME' field from the Grid part, 'current row'. 
        //Note that field name must be uppercase.
        {grid.object}.setValue('G','LASTNAME',{grid.rowNumber},'Smith');
        
        //Set value in 'LASTNAME' field in the Search part.
        {grid.object}.setValue('S','LASTNAME','Smith');
        
        //set value in 'LASTNAME' field in the Detail View part.
        {grid.object}.setValue('D','LASTNAME','Smith');
        
        //set the value in 'FAVORITECOLOR'. Assume that 'FAVORITECOLOR' is a multi-valued field (e.g. a Checkbox control or a Dropdown control configured to allow multiple values):
        {grid.Object}.setValue('S','FAVAORITECOLOR[]',['alpha','beta','gamma']);
        Notice that the fieldname has a trailing [] - to indicate that it is an array of values, and the values you want to set are passed in in the form of a Javascript array.
        
        //Setting value of 'range' fields in the Search part. You can't use .setValue(). You have to use low level Javascript.
        $('{grid.componentname}.S.STARTDATE').value = '12/1/2010';
        $('{grid.componentname}.S._TO.STARTDATE').value = '12/31/2010';
        Mike Brown - Contact Me
        Programmatic Technologies, LLC
        Programmatic-Technologies.com
        Independent Developer & Consultant​​

        Comment


          #5
          Re: Get and Set Values from a child grid to parent grid

          Mike
          The following works

          var po = {grid.Object}.getParentObject();

          //Get the values from the grid (you can define as many as you like)
          var firstname = {grid.object}.getValue('G','first_name',{grid.rowNumber});
          var lastname = {grid.object}.getValue('G','last_name',{grid.rowNumber});
          var city = {grid.object}.getValue('G','city',{grid.rowNumber});
          var cellphone = {grid.object}.getValue('G','last_name',{grid.rowNumber});
          var notify = {grid.object}.getValue('G','notify',{grid.rowNumber});
          //var Handicap = {grid.object}.getValue('G','HANDICAP',{grid.rowNumber});

          //If this Grid does not have a parent then 'po' will be false.
          if (po) {
          po.setValue('first_name',firstname);
          po.setValue('last_name',lastname);
          po.setValue('city',city);
          po.setValue('cellphone',cellphone);
          po.setValue('notify',notify);
          //po.setValue('Handicap',Handicap);


          }

          //Close the grid.
          {grid.Object}.closeContainerWindow(this);



          This does not work: (the only difference is what is in red)

          var po = {grid.Object}.getParentObject();

          //Get the values from the grid (you can define as many as you like)
          var firstname = {grid.object}.getValue('G','first_name',{grid.rowNumber});
          var lastname = {grid.object}.getValue('G','last_name',{grid.rowNumber});
          var city = {grid.object}.getValue('G','city',{grid.rowNumber});
          var cellphone = {grid.object}.getValue('G','last_name',{grid.rowNumber});
          var notify = {grid.object}.getValue('G','notify',{grid.rowNumber});
          var Handicap = {grid.object}.getValue('G','HANDICAP',{grid.rowNumber});

          //If this Grid does not have a parent then 'po' will be false.
          if (po) {
          po.setValue('first_name',firstname);
          po.setValue('last_name',lastname);
          po.setValue('city',city);
          po.setValue('cellphone',cellphone);
          po.setValue('notify',notify);
          po.setValue('Handicap',Handicap);


          }

          //Close the grid.
          {grid.Object}.closeContainerWindow(this);

          I was trying to keep it simple and copy a method that worked.

          Thanks for replying
          Tony

          Comment


            #6
            Re: Get and Set Values from a child grid to parent grid

            There is something going on with the handicap part of the grid then. It's the same syntax as your other code you said was working. That's the best I can offer with out sample components.

            Is handicap misspelled in either the parent or child grid?
            Mike Brown - Contact Me
            Programmatic Technologies, LLC
            Programmatic-Technologies.com
            Independent Developer & Consultant​​

            Comment


              #7
              Re: Get and Set Values from a child grid to parent grid

              I've checked and re-checked the spelling.
              Is this a normal and regular procedure ...... to set the value of a field (handicap) from table "x" (parent table) with a field (handicap) value from table "y" (child table)?
              If so, does it manner that the fields in each of the two tables ("x" and "Y") use the exact same field names?
              Thanks
              Tony

              Comment


                #8
                Re: Get and Set Values from a child grid to parent grid

                A sample component is needed. Setting data from parent to child and vice versa is a very normal thing that's done. It's a very straight forward method.
                Mike Brown - Contact Me
                Programmatic Technologies, LLC
                Programmatic-Technologies.com
                Independent Developer & Consultant​​

                Comment


                  #9
                  Re: Get and Set Values from a child grid to parent grid

                  what happens if it's all lowercase like everything else that works and shouldn't?
                  Insanity: doing the same thing over and over again and expecting different results.
                  Albert Einstein, (attributed)
                  US (German-born) physicist (1879 - 1955)

                  Comment


                    #10
                    Re: Get and Set Values from a child grid to parent grid

                    Hi Peter
                    I tried with all lower case and still it did not work ....

                    What about the select statement for child and the parent grid?

                    The field that I am not able to set a value for is "players.handicap" which is not in the select statement for the child grid.

                    Child Grid select statement
                    SELECT golfer_id, Handicap, first_name, last_name, address, city, state, zc, cellphone, email, notify
                    FROM golfers
                    ORDER BY last_name, first_name

                    Parent Grid select statement
                    SELECT *
                    FROM (Players Players
                    INNER JOIN Teams Teams
                    ON Players.Team_ID = Teams.Team_ID
                    INNER JOIN golfers golfers
                    ON Players.Golfer_ID = golfers.golfer_id )

                    Could that be my problem?
                    Thanks
                    Tony

                    Comment


                      #11
                      Re: Get and Set Values from a child grid to parent grid

                      Is there a value there?

                      do an alert..

                      var notify = {grid.object}.getValue('G','notify',{grid.rowNumber});
                      var Handicap = {grid.object}.getValue('G','HANDICAP',{grid.rowNumber});
                      alert(Handicap};[/QUOTE]
                      Insanity: doing the same thing over and over again and expecting different results.
                      Albert Einstein, (attributed)
                      US (German-born) physicist (1879 - 1955)

                      Comment


                        #12
                        Re: Get and Set Values from a child grid to parent grid

                        I just noticed you said this 'My problem is that I have tried to add a field to the "get value" and "set value" into the parent grid, but from a different table than the other fields.'
                        The question is what table and where do you get it? The value you are returning is coming from the same parent as the others. Maybe the join is wrong.
                        e.g. this simple select statement works, so check you are returning a value.
                        SELECT
                        *
                        FROM person person
                        INNER JOIN active active
                        ON person.Active = active.Active
                        Last edited by peteconway; 11-01-2019, 11:23 PM.
                        Insanity: doing the same thing over and over again and expecting different results.
                        Albert Einstein, (attributed)
                        US (German-born) physicist (1879 - 1955)

                        Comment


                          #13
                          Re: Get and Set Values from a child grid to parent grid

                          Peter
                          Below are my select statements

                          Player's Grid
                          Parent table is: Players
                          player_id
                          team_id
                          golfer_id
                          handicap

                          SELECT Players.Player_ID, Players.Team_ID, Players.Golfer_ID, Players.handicap, Teams.Team_ID AS Team_ID1, Teams.Tourn_ID, golfers.golfer_id AS golfer_id1, golfers.first_name, golfers.last_name, golfers.city, golfers.cellphone, golfers.handicap
                          FROM (Players PlayersI
                          INNER JOIN Teams Teams
                          ON Players.Team_ID = Teams.Team_ID
                          INNER JOIN golfers golfers
                          ON Players.Golfer_ID = golfers.golfer_id )

                          Golfer's (lookup) Grid
                          Child table is: Golfers
                          golfer_id
                          first_name
                          last_name
                          city
                          cellphone
                          handicap

                          SELECT golfer_id, first_name, last_name, city, cellphone, handicap,
                          FROM golfers
                          ORDER BY last_name, first_name

                          I can set the value of golfers.handicap in the players grid, from the value in the lookup grid - golfers.handicap
                          but still can't set the value of players.handicap in the players grid, from the value in the lookup gird - golfers.handicap

                          Thanks for your help
                          Tony

                          Comment


                            #14
                            Re: Get and Set Values from a child grid to parent grid

                            Have you tried putting a debugger in your javascript and looking at the process in Firefox or Chrome developers tools?
                            That might point out the issue.

                            Jay
                            Jay Talbott
                            Lexington, KY

                            Comment


                              #15
                              Re: Get and Set Values from a child grid to parent grid

                              Tony I can't get to not work, everything strait forward, send me your components, i'll take a look.
                              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