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 to Place Button on Bottom of GRID

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

    How to Place Button on Bottom of GRID

    Hello,

    I am trying to find out how to put a button on the bottom of a grid, then have it loop through the rows and write the data to a table based on if the row has a checkmark.

    Thanks

    Michael Carroll

    #2
    Re: How to Place Button on Bottom of GRID

    Originally posted by MichaelCarroll View Post
    Hello,

    I am trying to find out how to put a button on the bottom of a grid, then have it loop through the rows and write the data to a table based on if the row has a checkmark.

    Thanks

    Michael Carroll

    You will have to put the button in a freeform area below the grid.

    the button html will looks something like this

    <button onclick="docallback()">MyButton</button>



    docallback() will be a Javascript function that you write in the Javascript Function Declarations section of the Grid.

    It will do an ajax callback.


    To get you started, put use action scripting to put the button in the Grid row (you will see the button for each row in your grid). Then use action scripting to define an 'user defined ajax callback'.

    Right click on the action after you have defined it, and copy the javascript.

    Comment


      #3
      Re: How to Place Button on Bottom of GRID

      This video should help to get you started:

      http://www.screencast.com/t/NzI1NTIwN2E
      Bob Moore


      Comment


        #4
        Re: How to Place Button on Bottom of GRID

        Originally posted by Bob Moore View Post
        This video should help to get you started:

        http://www.screencast.com/t/NzI1NTIwN2E

        Great Video Bob. Thanks.

        It is worth noting that the 'e' object that is passed into the Xbasic function that executes on the server has in it a list of all of the rows that were checked.

        For example, this will be in 'e'
        if you clicked on 3 rows.

        checkboxRows.countChecked = 3
        checkboxRows.rows[] = 3
        checkboxRows.rows[] = 4
        checkboxRows.rows[] = 5
        checkedRows.key1[] = 00000004
        checkedRows.key2[] = 00000005
        checkedRows.key3[] = 00000006



        you can see:
        e.checkboxRows.countChecked is 3

        e.checkboxRows.rows is an array with an entry for each 3 that was submitted

        e.checkboxRows.keys[] is an array with the primary key of eaach row that was submitted.

        Comment


          #5
          Re: How to Place Button on Bottom of GRID

          Nice video.... stopped me in my tracks when I saw the cool integration to box.net

          Are you able to get the files in box.net to only show records related to the row you are on? Or does it simply show you all the files in your box?

          Very nice

          Comment


            #6
            Re: How to Place Button on Bottom of GRID

            I suppose you could but that is not what I have in mind. It will be the logged in users files.
            Bob Moore


            Comment


              #7
              Re: How to Place Button on Bottom of GRID

              Very helpful video Bob

              Alpha team: could all this copy-paste stuff be reduced if you included an action javascript button on the javascript declaration window?, just an idea because it does gets a little cofussing
              Cheers
              Mauricio

              Comment


                #8
                Re: How to Place Button on Bottom of GRID

                Thanks Bob and Selwyn,

                Ok I was able to duplicate what Bob did. Now I am on to parsing the selected items in the table and writing them to a SQL database. However I am running into a problem. Every time I go to save my code I get the following error and it truncates the code. Error: "Extra characters at the end of expression."

                I am trying to save the code in the "Xbasic Function declarations section" of properties.

                Here is the code:
                Code:
                function xb_AjaxCB as c (e as p)
                'xb_AjaxCB = "alert('Ajax Callback Fired')"
                'Need variable with parent link
                'Loop thorugh variable and pass data to SQL statement
                dim js as C
                dim i as N
                dim selectedcount as C
                'dim myrole as C
                dim myroleid as N
                dim mystaffid as N
                
                'get selected number of rows
                selectedcount=checkboxRows.countChecked
                for i=1 to selectedcount
                	myroleid=eval("e.checkedRows.key"+i+"[1]")
                	mystaffid="1" ' hard coded for now
                
                Dim Roles_Id_Roles as N
                Dim Co_Staff_Id_Staff as N
                
                'Insert a new record into a remote SQL database.
                'DIM a connection variable
                DIM cn as SQL::Connection
                dim flagResult as l 
                flagResult = cn.open("::Name::FS1MySQL")
                if flagResult = .f. then 
                	"alert('Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text')"
                	end 
                end if
                
                cn.PortableSQLEnabled = .t.
                
                'Dim a SQL arguments object, create arguments and set their values
                DIM args as sql::arguments
                
                args.add("Roles_Id_Roles",myroleid)
                args.add("Co_Staff_Id_Staff",mystaffid)
                
                dim sqlInsertStatement as c 
                sqlInsertStatement = <<%txt%
                INSERT INTO co_staff_has_roles  (Roles_Id_Roles, Co_Staff_Id_Staff) 
                VALUES (:Roles_Id_Roles, :Co_Staff_Id_Staff)
                %txt%
                
                dim flag as l 
                flag = cn.Execute(sqlInsertStatement,args)
                if flag = .f. then 
                	"Alert('Record was not inserted. Error reported was: ' + crlf(2) + cn.CallResult.text)"
                else
                	if cn.AffectedRows() = 1 then 
                		"Alert('Record was created.')"
                	else
                		"Alert('Record was not inserted.')"
                	end if 
                end if 
                
                	
                'Table has an auto-increment field. Get the value that was assigned to this field and store it in
                'a variable.	
                dim LastIdentityValue as C
                if cn.AffectedRows() = 1 then 
                	LastIdentityValue = cn.LastInsertedIdentity()
                end if 
                'Now, close the connection 
                cn.close()
                
                Next
                
                js="alert('Selected Records Processed')"
                xb_AjaxCB=js
                
                end function
                When I click the Ok button I get the error message and if I open it up again I get the following code.

                Code:
                function xb_AjaxCB as c (e as p)
                'xb_AjaxCB = "alert('Ajax Callback Fired')"
                'Need variable with parent link
                'Loop thorugh variable and pass data to SQL statement
                dim js as C
                dim i as N
                dim selectedcount as C
                'dim myrole as C
                dim myroleid as N
                dim mystaffid as N
                
                'get selected number of rows
                selectedcount=checkboxRows.countChecked
                for i=1 to selectedcount
                	myroleid=eval("e.checkedRows.key"+i+"[1]")
                	mystaffid="1" ' hard coded for now
                	
                Roles_Id_Roles, Co_Staff_Id_Staff
                
                
                
                Next
                js="alert('Selected Records Processed')"
                xb_AjaxCB=js
                
                end function
                Thanks again for everyones help.

                Michael Carroll

                Comment


                  #9
                  Re: How to Place Button on Bottom of GRID

                  Looks like the line

                  Code:
                  "alert('Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text')"
                  should be

                  Code:
                  "alert('Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text+"')"
                  There can be only one.

                  Comment


                    #10
                    Re: How to Place Button on Bottom of GRID

                    Stan,

                    Did not work. So for good measure I took out all alerts and still get the same message. Here is my amended code:

                    Code:
                    function xb_AjaxCB as c (e as p)
                    'Need variable with parent link
                    'Loop thorugh variable and pass data to SQL statement
                    dim js as C
                    dim i as N
                    dim selectedcount as C
                    'dim myrole as C
                    dim myroleid as N
                    dim mystaffid as N
                    'get selected number of rows
                    selectedcount=checkboxRows.countChecked
                    for i=1 to selectedcount
                    	myroleid=eval("e.checkedRows.key"+i+"[1]")
                    	mystaffid="1" ' hard coded for now
                    Dim Roles_Id_Roles as N
                    Dim Co_Staff_Id_Staff as N
                    'Insert a new record into a remote SQL database.
                    'DIM a connection variable
                    DIM cn as SQL::Connection
                    cn.open("::Name::FS1MySQL")
                    cn.PortableSQLEnabled = .t.
                    'Dim a SQL arguments object, create arguments and set their values
                    DIM args as sql::arguments
                    args.add("Roles_Id_Roles",myroleid)
                    args.add("Co_Staff_Id_Staff",mystaffid)
                    dim sqlInsertStatement as c 
                    sqlInsertStatement = <<%txt%
                    INSERT INTO co_staff_has_roles  (Roles_Id_Roles, Co_Staff_Id_Staff) 
                    VALUES (:Roles_Id_Roles, :Co_Staff_Id_Staff)
                    %txt%
                    cn.Execute(sqlInsertStatement,args)
                    cn.close()
                    Next
                    js="alert('Selected Records Processed')"
                    xb_AjaxCB=js
                    end function
                    Last edited by MichaelCarroll; 02-18-2010, 08:58 PM. Reason: Formatting

                    Comment


                      #11
                      Re: How to Place Button on Bottom of GRID

                      Not that I have a clue what's going on but this looks strange

                      myroleid=eval("e.checkedRows.key"+i+"[1]")

                      could it possibly supposed to have a period before [1] ?

                      myroleid=eval("e.checkedRows.key"+i+".[1]")

                      as in array syntax?
                      There can be only one.

                      Comment


                        #12
                        Re: How to Place Button on Bottom of GRID

                        I haven't studied your code, but looking at Stan's suggestion I notice that you seem to be mixing JavaScript w. xbasic. You can't put a crlf() xbasic function in a JS alert function.
                        Peter
                        AlphaBase Solutions, LLC

                        [email protected]
                        https://www.alphabasesolutions.com


                        Comment


                          #13
                          Re: How to Place Button on Bottom of GRID

                          Originally posted by Stan Mathews View Post
                          Not that I have a clue what's going on but this looks strange

                          myroleid=eval("e.checkedRows.key"+i+"[1]")

                          could it possibly supposed to have a period before [1] ?

                          myroleid=eval("e.checkedRows.key"+i+".[1]")

                          as in array syntax?
                          Makes no difference.

                          Thanks though.

                          Comment


                            #14
                            Re: How to Place Button on Bottom of GRID

                            Originally posted by Peter.Greulich View Post
                            I haven't studied your code, but looking at Stan's suggestion I notice that you seem to be mixing JavaScript w. xbasic. You can't put a crlf() xbasic function in a JS alert function.
                            Peter, I dropped all alerts from the code and still get the error.

                            From what I understand this is where you can use both xbasic and java.

                            Interesting, If I comment out everything between Funtion xb_AjaxCB c (e as p) and end function I still get the error.

                            If I go back to just firing off the alert then I can save it.

                            Michael

                            Comment


                              #15
                              Re: How to Place Button on Bottom of GRID

                              Originally posted by Stan Mathews View Post
                              Not that I have a clue what's going on but this looks strange

                              myroleid=eval("e.checkedRows.key"+i+"[1]")

                              could it possibly supposed to have a period before [1] ?

                              myroleid=eval("e.checkedRows.key"+i+".[1]")

                              as in array syntax?

                              this is correct.

                              Code:
                              myroleid = eval("e.checkedRows.key"+i+"[1]")
                              when 'i' is 1 for example, then it evaluates to:

                              Code:
                              myroleid = eval("e.checkedRows.key1[1]")

                              which is correct.

                              Comment

                              Working...
                              X