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

Adding rows to a repeating section of a UX

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

    Adding rows to a repeating section of a UX

    Is there a way to add rows to a repeating section based on the number of records in a table?

    I've got an Ajax callback function that gets the child records from a similar record and pastes it into the repeating section of the current record. The table is a local .dbf, and this is the code:
    Code:
    	
    dim count as n = 1
    	While DuplicatingRecord.nextrow()
    		eval("e._set.SKU_A5INSTANCE" + count + ".value") = DuplicatingRecord.sku					' -- sets repeating section of row "count" to the Duplicating Record
    		eval("e._set.description_A5INSTANCE" + count + ".value") = DuplicatingRecord.description
    	        eval("e._set.lineTotal" + count + ".value") = DuplicatingRecord.linetotal
    		count = count + 1
    	end while
    It works fine as long as I have enough rows in the repeating section, but I don't know how many repeating rows I'll need until I'm doing the ajax callback. Then, once I'm doing the callback, I don't know how to send back to the browser that I'll need more or less rows.

    Thanks for reading!
    Brad Steinfeldt

    #2
    Re: Adding rows to a repeating section of a UX

    Do the callback, then use this javascript to set the row count:

    {dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',8,true,false);

    Of course, you will have to replace the 8 with your callback result.
    You can probably do it in the OnDialogInitialize server-side event, and plug the row count into the string of javascript, then send the jsString to the browser with:

    e.javascript = jsString

    repeatingSection.png

    Jay
    Jay Talbott
    Lexington, KY

    Comment


      #3
      Re: Adding rows to a repeating section of a UX

      Thanks Jay,

      I'm just learning callback, but if I understand correctly, e.javascript is a JavaScript command that will be passed back to the browser after the function closes?
      So in my function, I would put in a line of code like:
      e.JavaScript = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1'," + count + ",true,false);"
      Brad Steinfeldt

      Comment


        #4
        Re: Adding rows to a repeating section of a UX

        Yes, because this works on my UX:
        rowCount = 6
        js = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',"+rowCount+",true,false);"
        e.javascript = js

        You can combine the last two lines like you did, or you can leave them separate, which sometimes helps with debugging.
        Jay Talbott
        Lexington, KY

        Comment


          #5
          Re: Adding rows to a repeating section of a UX

          I've attempted what you outlined, but I'm doing something wrong. The e.javascript command isn't doing the command back on the browser. I've dumbed everything down, but still have a problem.
          This is my xbasic function:
          2020-02-13.png

          This is my ajax Callback script definition:
          2020-02-13 -2.png

          This is the debug variables prior to ending the function:
          2020-02-13 -3.png

          Thanks again for your help. If you're getting it to work, at least I know it can be done.
          Brad Steinfeldt

          Comment


            #6
            Re: Adding rows to a repeating section of a UX

            Brad, there is a confusion between an Ajax Callback and the onDialogInitialize event.

            onDialogInitialize can return e.javascript.

            An Ajax Callback does not return e.javascript. But your Ajax Callback code is almost correct.

            Remove the e.javascript line. And then assign DupChosenRec to your js variable.

            Javascript is returned from the server to the client in the Ajax Callback name.

            Code:
            DupChosenRec = js

            Comment


              #7
              Re: Adding rows to a repeating section of a UX

              I was under the impression that you were doing this on the OnDialogInitialize event under system events.
              If you put your Xbasic on the OndialogInitialize event, you need to use the e.javascript.
              If you are doing this as an AJAX callback you need to do what David suggests.

              Hope this helps.

              Jay
              Jay Talbott
              Lexington, KY

              Comment


                #8
                Re: Adding rows to a repeating section of a UX

                Thanks David and Jay. It makes sense.

                I did as you suggested, and it semi-worked. It created the correct row count, but it didn't pass the data back into the newly created rows, only to any previously existing rows. I clicked the button a second time, and it filled the rest of them in, but...

                I tried moving the function declaration line (if that's the right way to describe it) to be in front of the row writing line as shown in the code below:

                Code:
                Function DupChosenRec as c (e as p) 
                	dim dupartsfrom.description as c = e.datasubmitted.description
                	dim count as n = 5
                	js = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',"+count+",true,false);"
                        DupChosenRec = js
                	count = 1
                	for count = 1 to 5
                		eval("e._set.descriptionR_A5INSTANCE" + count + ".value") = dupartsfrom.description
                	next count 
                end function
                But, that didn't do anything. I assume that "DupChosenRec = js" only fires at the end of the running of the function, no matter where it's placed in the function.

                I'm going to next try creating two separate functions with two separate Ajax Callbacks, one to adjust the repeating sections row count and then a second to fill it in I'll see if that works as a workaround, unless there's a better suggestion.

                Thanks again for the help.
                Brad Steinfeldt

                Comment


                  #9
                  Re: Adding rows to a repeating section of a UX

                  That worked. I don't know if that's the best way to do it, or if the other way should work, but at least this work.
                  Brad Steinfeldt

                  Comment


                    #10
                    Re: Adding rows to a repeating section of a UX

                    Could you paste in both your callbacks. It's kind of clear what you want to do, but the code would help.
                    Following proper coding technique DupChosenRec = js should be the last, or nearly last, statement processed.
                    How are you setting the repeating section values?

                    You want to create a new set of RS rows, based on a SQL count, and then fill in those rows... all from an Ajax Callback... is that right?

                    Comment


                      #11
                      Re: Adding rows to a repeating section of a UX

                      I created these two separate functions in the xbasic function declaration:

                      Code:
                      Function RecordCount as c (e as p) 
                      '	debug(1)
                      	dim count as n = 5
                      	js = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',"+count+",true,false);"
                      	RecordCount = js
                      end function
                      
                      
                      
                      Function DupChosenRec as c (e as p) 
                      '	debug(1)
                      	dim dupartsfrom.description as c = e.datasubmitted.description
                      	dim count as n 
                      	count = 1
                      	for count = 1 to 5
                      		eval("e._set.descriptionR_A5INSTANCE" + count + ".value") = dupartsfrom.description
                      	next count 
                      end function
                      Then, on the onclick event of a button, I do two ajax callbacks. I just used action scripting like this:
                      2020-02-13 6.png

                      The JavaScript behind the scenes is:

                      Code:
                      {dialog.object}.ajaxCallback('','','RecordCount','','',{chunkedResponses: {allow: false},deviceOfflineFunction: function() {   }}); ' RecordCount function
                      {dialog.object}.ajaxCallback('','','DupChosenRec','','',{chunkedResponses: {allow: false},deviceOfflineFunction: function() {   }}); 'DupChosenRec function
                      I'll post a second reply to answer your other questions.
                      Brad Steinfeldt

                      Comment


                        #12
                        Re: Adding rows to a repeating section of a UX

                        In reply to you statement,
                        Following proper coding technique DupChosenRec = js should be the last, or nearly last, statement processed.
                        I was just trying to see if it made any difference, but it didn't. I moved it back to the last line of the function.

                        As for this question,
                        How are you setting the repeating section values?
                        In the test UX I just used a For/Next loop. In my original UX, I used a While .nextrow() command to step through the records (I'm using local .dbf files), and then I wrote the data using the command "eval("e._set.descriptionR_A5INSTANCE" + count + ".value") = dupartsfrom.description".

                        As for your question,
                        You want to create a new set of RS rows, based on a SQL count, and then fill in those rows... all from an Ajax Callback... is that right?
                        Yes, but I'm using local .dbf files. I'm looking up the .dbf table to get the record count. The first ajax callback sets the number of repeating rows I need. Then, the second callback will get the data and put it into those repeating sections.
                        Basically, I'm looking up the parts in a similar record that is already existing in the table, and I then using those child records to bring them back into my UX of the record I'm working with where I can edit things a little here and there and then save it. It's meant to speed up some data entry.
                        Brad Steinfeldt

                        Comment


                          #13
                          Re: Adding rows to a repeating section of a UX

                          I wouldn't make 2 callbacks. Just make one... and build your response in the callback. The problem with making 2 callbacks... from Javascript... is that Javascript is asynchronous. You don't know which will finish first.

                          You don't need the vofr count = 1. count is set to 1 in the for loop code.

                          Using e._set is ok, but not really the best way. That code gets converted by Alpha into {dialog.Object}.setValue(). So, just do that anyway.

                          Code:
                          function DupChosenRec as c (e as p)
                          	
                          dim count as n
                          dim setVal as c = ""
                          for count = 1 to 5
                          	setVal = setVal + "{dialog.object}.setValue('LASTNAME:" + count + "','Smith');"
                          next count	
                          
                          dim rsCount as n = 5
                          DupChosenRec = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',"+rsCount+",true,false);" + setVal
                          	
                          end function

                          Comment


                            #14
                            Re: Adding rows to a repeating section of a UX

                            David,
                            I'm having problems with converting my test UX to the other UX-- getting some weird results. Maybe that's because of the asynchronous nature JavaScript. I'm going to give your suggested code a try.
                            Last edited by acceptthis; 02-14-2020, 12:08 PM.
                            Brad Steinfeldt

                            Comment


                              #15
                              Re: Adding rows to a repeating section of a UX

                              David or anyone,

                              I'm still having a problem, even with the way you've created the function, and I think I've figured it out. If you get a chance to test it on your end, I'd be interested if you could produce the error as well. I placed a button on the UX, so I could change the row count on the fly. Here's the code:

                              Code:
                              Function DupChosenRec as c (e as p) 
                              	dim count as n
                              	dim setVal as c = ""
                              	for count = 1 to val(e.dataSubmitted.Quantity)
                              		setVal = setVal + "{dialog.object}.setValue('LASTNAME:" + count + "','Smith');"
                              	next count	
                              	
                              	dim rsCount as n = val(e.dataSubmitted.Quantity)
                              	DupChosenRec = "{dialog.Object}._setRepeatingSectionRowCount('REPEATINGSECTION_1',"+rsCount+",true,false);"+ setVal  
                              end function

                              1. Start with a default row count of 5.
                              2. Change it to 6 and test it. No problem.
                              3. Change it to 8 and test. No problem.
                              4. Change it to 3. No problem.
                              5. Change it to 5, or something bigger, and I get problems. The last 2 rows, 4 and 5, don't get written.
                              6. Change it to 10, and only 5 are written.

                              It seems that once you lessen the row count, that lesser row count becomes a "semi-default". It can be brought back up by entering in larger and larger numbers, but I haven't figure out the formula to predict it. All I can predict is that entering a lower number below what's being filled in will get it to fill in all the rows.

                              I hope to see if others are able to duplicate the error. If not, I'm the one that's screwed.

                              Brad
                              Brad Steinfeldt

                              Comment

                              Working...
                              X