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 Populate Data from other Tables

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

    #31
    Re: UX Populate Data from other Tables

    also i am just stumped.
    if you just want to fill in student data why not resort to auto suggest and fill in field sleet alpha do it for you instead of doing all this coding?
    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


      #32
      Re: UX Populate Data from other Tables

      Originally posted by GGandhi View Post
      if you need only information from the student table you don't need to connect to other tables for populating
      the select statement will be
      Code:
      sqlSelect = <<%sql%
      SELECT * 
      FROM sen_ipm_header sen_ipm_header
             INNER JOIN student_table_name student_table_name
                         ON sen_ipm_header.student_id = student_table_name.id
      WHERE id = :newID
      %sql%
      args.add("newID", id)
      this will give you all the student information. looks like you don't need other information from your last post.

      Comment


        #33
        Re: UX Populate Data from other Tables

        GHANDI

        This the error that I am getting and I need all of the Tables.

        Chris

        Error executing onDialogExecute event: Xbasic Event: onDialogInitialize Syntax error in Xbasic: Could not compile code: Missing or invalid keyword function populate as c (e as p) debug(1) dim id as n id = e.dataSubmitted.ipm_id dim cn as sql::Connection dim args as sql::Arguments dim result as l dim rs as sql::ResultSet result = cn.Open("::Name::conn") if result dim sqlSelect as c sqlSelect = <<%sql% SELECT * FROM (sen_ipm_header sen_ipm_header INNER JOIN sen_ipm_ara sen_ipm_ara ON sen_ipm_header.ipm_id = sen_ipm_ara.ipm_id INNER JOIN sen_ipm_progress sen_ipm_progress ON sen_ipm_header.ipm_id = sen_ipm_progress.ipm_id INNER JOIN sen_ipm_provision sen_ipm_provision ON sen_ipm_header.ipm_id = sen_ipm_provision.ipm_id ) WHERE id = :newID %sql% args.add("newId", id) result = cn.Execute(sqlSelect,args) if result rs = cn.ResultSet e._set.student_id.value = rs.data("student_id") 'e._set.firstname.value = rs.data("firstname") 'e._set.address1.value = rs.data("address1") 'e._set.address2.value = rs.data("address2") 'e._set.city.value = rs.data("city") 'e._set.zipcode.value = rs.data("zipcode") 'e._set.date_of_birth.value = rs.data("date_of_birth") end if cn.close else populate = "alert('could not connect to database');" end if end function function onDialogInitialize as v (e as p) 'Request - The Request object. Includes Request.Variables, which should be used instead of the older e.rv construct 'Session - The Session object. Should be used instead of the older e.session construct 'Inside e: 'e.tmpl = Component definition 'e.rtc = Runtime calculations - you can use this to store data to be passed to other server side events (Note: the 'rtc' object cannot be used to persist state information - i.e. you can't set a value in rtc and then read that value in a subsequent callback. To persist state info see e._state). 'e.arguments = SQL::Arguments object with values for each of the arguments defined in this component. To read a value from arguments: e.arguments.find("argumentName").data 'You can set the initial value of any field by setting the property (see comment at end for Javascript technique to use when setting values for a large number of controls) 'e.control. 'For example: 'e.control.firstname = "Fred" 'e.control.lastname = "Jones" 'To set the value of a field in a repeating section, you must use "_A5INSTANCE" and the instance number as a suffix on the fieldname. 'For example: 'e.control.firstname_A5INSTANCE2 = "Bob" 'sets the value in the 2nd row of the repeating section. 'To specify any javascript that you want to execute set the e.javascript property. For example: 'e.javascript = "alert('hello');" 'You can set 'state' variables in this event. The value of any state variables will be available in all subsequent ajax callbacks. 'To set a state variable: 'e._state.myvar1 = "value1" 'e._state.myvar2 = "value2" 'To edit this action, place insertion point anywhere in the command, then click the 'Action Scripting' button'. 'ExecuteServerSideAction("Populate Dialog from Tables::Populate_a_Dialog_with_data_from_one_or_more_tables") 'Using Javascript to Set Control Values and the Row Count in a Repeating Section -- Recommended For Maximum Efficiency (Advanced users) '--------------------------------------------------------------------------------------------------------------------------- 'When setting the value of a large number of controls, you will improve performance if you generate the Javascript directly, 'rather than setting properties in the e.control object (as described above) and then having Alpha Five generate the Javascript from this object. 'The following example shows Javascript code that sets the number of rows in a Repeating Section and sets the value of various control 'in the top section and Repeating Section of the Dialog: 'Generate the Javascript to emit 'dim js as c 'js = <<%txt% 'var rows = 7; 'var setFocusToFirst = true; 'var nullOutExistingData = true; 'var repeatingSectionId = 'CONTAINER_1'; 'DLG1_DlgObj._setRepeatingSectionRowCount(repeatingSectionId,rows,setFocusToFirst,nullOutExistingData); 'var _d = {}; '//Next command is optional. It is ONLY needed if the ._setRepeatingSectionRowCount() method has been called. '//The command copies default values into the _d object. Without this command, default values defined in the component will not be set. '//$u.o.assign(_d,DLG1_DlgObj.originalValues[0]); '_d['B'] = 'alpha'; //set the value of a control called 'B' '_d['E:2'] = 'beta'; //set the value of a control called 'E' in the 2nd Repeating Section row '_d['G:6'] = ['Red','Green']; //set the value of a checkbox called 'G' in the 6th Repeating Section row to 'Red' and 'Green' 'DLG1_DlgObj.prepare(); 'DLG1_DlgObj.populate(_d); 'DLG1_DlgObj.refreshClientSideComputations(); '%txt% 'Now, emit the Javascript... 'e.javascript = js 'NOTE: In the above example, if the ._setRepeating() method is called in the 'onDialogInitialize' event, you are responsible for setting 'values in ALL of the controls in the component. For example, if you have defined default values for some controls, and then set the values 'of other controls using the .populate() method, only the values set in the _d object will be set. (The default values will NOT be set). 'You can, however, put the default values into the _d object using this code: '$u.o.assign(_d,DLG1_DlgObj.originalValues[0]); 'Tip: You can use the xbasic varToJSON() function to help generate the Javascript object passed to the .populate() method. 'For example: 'dim j as p 'j.firstname = "John" 'j.lastname = "Smith" 'j.quantity_a5instance1 = "2" 'dim j.colorchoices_a5instance2[3] as c 'j.colorchoices_a5instance2[1] = "Red" 'j.colorchoices_a5instance2[2] = "Blue" 'dim jsTxt as c 'jsTxt = varToJSON(j) 'js = "DLG1_DlgObj.populate(" + jsTxt + "); DLG1_DlgObj.prepare();" end function

        Comment


          #34
          Re: UX Populate Data from other Tables

          did you add the arguments as I mentioned in post #29?
          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


            #35
            Re: UX Populate Data from other Tables

            function populate as c (e as p)

            debug(1)
            dim id as n
            id = e.dataSubmitted.ipm_id
            dim cn as sql::Connection
            dim args as sql::Arguments
            dim result as l
            dim rs as sql::ResultSet

            result = cn.Open("::Name::conn")
            if result
            dim sqlSelect as c
            sqlSelect = <<%sql%
            SELECT *
            FROM (sen_ipm_header sen_ipm_header
            INNER JOIN sen_ipm_ara sen_ipm_ara
            ON sen_ipm_header.ipm_id = sen_ipm_ara.ipm_id
            INNER JOIN sen_ipm_progress sen_ipm_progress
            ON sen_ipm_header.ipm_id = sen_ipm_progress.ipm_id
            INNER JOIN sen_ipm_provision sen_ipm_provision
            ON sen_ipm_header.ipm_id = sen_ipm_provision.ipm_id )
            WHERE ipm_id = :newID
            %sql%
            args.add("newID", id)
            result = cn.Execute(sqlSelect,args)
            if result
            rs = cn.ResultSet
            e._set.student_id.value = rs.data("student_id")
            'e._set.firstname.value = rs.data("firstname")
            'e._set.address1.value = rs.data("address1")
            'e._set.address2.value = rs.data("address2")
            'e._set.city.value = rs.data("city")
            'e._set.zipcode.value = rs.data("zipcode")
            'e._set.date_of_birth.value = rs.data("date_of_birth")

            end if

            cn.close
            else
            populate = "alert('could not connect to database');"
            end if

            end function
            Last edited by GGandhi; 03-20-2014, 12:03 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


              #36
              Re: UX Populate Data from other Tables

              Ghandi

              I did

              This is the current code:-

              function populate as c (e as p)

              debug(1)
              dim id as n
              id = e.dataSubmitted.ipm_id
              dim cn as sql::Connection
              dim args as sql::Arguments
              dim result as l
              dim rs as sql::ResultSet

              result = cn.Open("::Name::conn")
              if result
              dim sqlSelect as c
              sqlSelect = <<%sql%
              SELECT *
              FROM (sen_ipm_header sen_ipm_header
              INNER JOIN sen_ipm_ara sen_ipm_ara
              ON sen_ipm_header.ipm_id = sen_ipm_ara.ipm_id
              INNER JOIN sen_ipm_progress sen_ipm_progress
              ON sen_ipm_header.ipm_id = sen_ipm_progress.ipm_id
              INNER JOIN sen_ipm_provision sen_ipm_provision
              ON sen_ipm_header.ipm_id = sen_ipm_provision.ipm_id )
              WHERE id = :newID
              %sql%
              args.add("newId", id)

              result = cn.Execute(sqlSelect,args)
              if result
              rs = cn.ResultSet
              e._set.student_id.value = rs.data("student_id")
              'e._set.firstname.value = rs.data("firstname")
              'e._set.address1.value = rs.data("address1")
              'e._set.address2.value = rs.data("address2")
              'e._set.city.value = rs.data("city")
              'e._set.zipcode.value = rs.data("zipcode")
              'e._set.date_of_birth.value = rs.data("date_of_birth")

              end if

              cn.close
              else
              populate = "alert('could not connect to database');"
              end if

              end function

              Comment


                #37
                Re: UX Populate Data from other Tables

                WHERE id = :newID
                I was copying from my table
                it should be
                WHERE sen_ipm_header.ipm_id = :newID
                sorry about that
                Last edited by GGandhi; 03-20-2014, 02:04 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


                  #38
                  Re: UX Populate Data from other Tables

                  Also I am testing in my local system, I will post back later any progress
                  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


                    #39
                    Re: UX Populate Data from other Tables

                    okay
                    I made dummy tables in mssql 2012 and created a dialog and populated with a button from these three tables
                    take a look
                    http://screencast.com/t/xmhXSxvi
                    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


                      #40
                      Re: UX Populate Data from other Tables

                      I guess I didn't understand this one at all.

                      I thought you had a UX with a Parent table and several Child tables all with a One-to-Many relationship.

                      In a UX this would present itself as a Parent section with Repeating Sections for the children.

                      Then I thought the process was to select a current record from a dropdown and make a copy of a that record (Parent and Children) keeping in mind that the Parent and children keys were all auto-increment... that the Parent Key, used as a link to the Children, was auto-increment.

                      Comment


                        #41
                        Re: UX Populate Data from other Tables

                        I tried to do different ways, I am not able to populate the repeating sections.
                        sorry.
                        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


                          #42
                          Re: UX Populate Data from other Tables

                          I don't think you need to go back to the tables to accomplish this. The UX, after populated, carries all the data for the parent and child tables... the parent and repeating sections.

                          Since all the data is available there's only one issue... the autonumber key for the parent... which is the linking key for the child. You can't create the child without first saving the parent.

                          The attached video and UX accomplish this by:

                          1. Saving all the data from the record, parent and child, to a session variable.
                          2. Using that data to create a Parent record and saving it.
                          3. Using the saved Parent data key (now available from step 2) to build and save the child.

                          You never have to go back to the tables for data and you never have to worry about adjusting your code because you added or removed fields on the UX.

                          http://www.youtube.com/watch?v=ELRRx60ZVSg

                          The attached UX is data bound so it won't work on another system but the code is the important bit and it's all there.
                          Attached Files

                          Comment


                            #43
                            Re: UX Populate Data from other Tables

                            Thanks both and sorry for the delay in getting back to you. I have had a few days vacation.

                            I have added the code and changed the bits I think need changing and while I think I understand the logic and some of the code. The problem I am having is that the Header record is saving but is blank and I cannot get it to load any data from the current record.

                            I have attached the component with the code in it and would appreciate it if you can give me some pointers.
                            Also I have multiple repeating sections - have I setup the autonumber code for tat correctly.

                            David the video is fantastic -

                            Chris
                            Attached Files

                            Comment


                              #44
                              Re: UX Populate Data from other Tables

                              Chris,

                              If you want to export your tables, with data, and post them or send them, then I can have a look.

                              Comment

                              Working...
                              X