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

Delete all repeating section rows when resetting a V11 dialog

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

    Delete all repeating section rows when resetting a V11 dialog

    Hi

    I have a fairly complex web dialog control with some header fields and a repeating section. The form uses javascript to populate the repeating section based on selections made in a 3-tiered grid in a pop-up window. The 3-tiered grid starts with a list of tool groups - the selection of a tool group updates a linked grid with tool categories and a selection in the tool category grid updates a linked grid with tool types in the selected category. When the user clicks on a selection in the tool types grid, the code either adds a new repeating section line with that tool type or updates the count on an existing repeating section line if the tool type is already in the repeating section.

    When the dialog opens initially, the {dialog.Object}.deleteRepeatingSectionRow(sectionName) method runs to delete the initial repeating section row so the user starts with a blank form. Alpha does not prompt to confirm the delete of this first repeating section row and I would assume that it is because the row is not yet dirty.

    When the user makes a selection in the pop-up grid, the code adds a record to the repeating section and then populates it with data from the grid row (as explained above).

    When the user presses the reset button on the main dialog, the dialog header fields are emptied and the repeating section lines are emptied. However, I would like to have the reset button "remove" the repeating section rows and not just empty them.

    I have added some javascript to iterate through the active repeating section rows to delete them but when I use the {dialog.Object}.deleteRepeatingSectionRow(sectionName) method in this case, Alpha prompts for confirmation to delete each repeating section row. I would assume that this is because the rows are now dirty. How do I delete all the repeating section rows without having to confirm the delete of each one?

    Thanks,
    Peter

    #2
    Re: Delete all repeating section rows when resetting a V11 dialog

    Give this a try. This code comes from the Alpha generated examples when you create an Ajax Callback. I've tried various combinations of flags but cannot get the row delete confirm msg to go away. However, you can set the rows to zero and so, I think, achieve what you want to. You may not even need a lot of this but here it is. I'm not sure what overall effect this has on the dialog... e.g. are all the rows still there??? Doesn't seem so based on the code being executed... but something to keep in mind. This is an Ajax Callback, so set it up as such.

    Code:
    function DeleteRRows as c (e as p)
    	
    'Generate the Javascript to emit
    dim jsToSetControlValues as c 
    jsToSetControlValues = <<%jstxt%
    var rows = 0;
    var setFocusToFirst = true;
    var nullOutExistingData = true;
    var repeatingSectionId = 'CONTAINER_1';
    {dialog.object}._setRepeatingSectionRowCount(repeatingSectionId,rows,setFocusToFirst,nullOutExistingData);
    var _d = {};
    {dialog.object}.prepare();
    var flagSetDialogClean = true;
    var flagFireChangeEvents = true;
    {dialog.object}.populate(_d,1,flagSetDialogClean,flagFireChangeEvents);
    {dialog.object}.refreshClientSideComputations();
    
    %jstxt%
    
    'Return the Javascript code
    DeleteRRows = jsToSetControlValues
    
    end function

    Comment


      #3
      Re: Delete all repeating section rows when resetting a V11 dialog

      First I want to thank you David for the response and code suggestion. Glad to see another Canadian on the msg board! I have been working in VBA and Access since 1998 and am currently converting one of my applications to Alpha/Javascript. I have managed to make some good progress using several of Richard's videos and the Firebug DOM viewer but my understanding of Javascript is still a bit limited.

      I reviewed the code you suggested and the var flagSetDialogClean line jumped off the page. Since I have been able to get the client Javascript to add the lines to the form, I was determined to get the client javascript to remove the lines as well. Your code suggestion made me revisit the idea of having "dirty" lines in the repeating section, causing the deleteRepeatingSectionRow(sectionName) function to prompt for confirmation from the user.

      I used the Firebug DOM viewer to review the complete code in the deleteRepeatingSectionRow(sectionName) function and found the following code piece:

      Code:
      deleteRepeatingSectionRow: function(sectionName) {
      	var flagSilent = typeof arguments[2] != 'undefined' ? arguments[2] : false;
      	var rs = this.repeatingSections[sectionName];
      	var rowNum = 1;
      	var instNum = typeof arguments[1] != 'undefined' ? arguments[1] : -1;   ......
      A little further down, the function tests the flagSilent variable and the flagDirty variable

      Code:
      if(flagSilent == false && flagDirty == true) {
      and if false and true respectively, the function then goes on to prompt the user for confirmation. If flagSilent is true, the function skips the user confirmation prompt and just deletes the row regardless of whether or not it is dirty.

      Since I could see that the flagSilent variable was being set based on something in the arguments list, I did some Google research and found this post with a good description of how Javascript handles arguments passed to functions.

      http://www.ifadey.com/2010/11/javasc...ton-arguments/

      Turns out that arguments are passed to a Javascript function as a zero based array and you can indeed pass in more arguments than the function specifies in its definition like this

      Code:
      deleteRepeatingSectionRow(sectionName,[COLOR="#800080"]physical row number,Silent[/COLOR]);
      To understand how the deleteRepeatingSectionRow function is setting flagSilent, another Google search produced this explanation of setting values using either if/else, conditional operators or And/Or operators.

      http://www.thomasfrank.se/3_ways_2_say_if.html

      The var flagSilent line in the function

      Code:
      var flagSilent = [COLOR="#008000"]typeof arguments[2] != 'undefined'[/COLOR] [COLOR="#0000FF"]? arguments[2][/COLOR] [COLOR="#800080"]: false;[/COLOR]
      is using conditional operators so it reads like this in English:

      "If the type of the 3rd argument (arguments[2]) is not equal to 'undefined' (i.e. the argument was indeed passed to the function), then (?) set flagSilent to the value of the 3rd argument otherwise (:) set flagSilent to false."

      So, if you want to use the deleteRepeatingSectionRow function to delete the active row without prompting the user for confirmation, regardless of whether the row is dirty or not, you can send along the additional argument for "silent" as the 3rd argument in the function call. If you leave out the instance (row) number (the second argument), then the function will operate on the active row.

      Code:
      deleteRepeatingSectionRow(sectionName[COLOR="#800080"],'',true[/COLOR]);
      In my case, I wanted to delete ALL of the repeating section rows. To do this, I needed to get the count of active records in the repeating section. I went back to the DOM in Firebug and found a function for this:

      Code:
      var repSectRows = {dialog.Object}._getRepeatingSectionRowCount(sectionName);
      The row count is the count of ACTIVE rows, not including deleted rows. Since we are dealing with ACTIVE rows, before we specify a row number in the deleteRepeatingSectionRow function, we must look up the PHYSICAL row number using the function

      Code:
      var row = {dialog.object}._repeatingSectionLogicalToPhysicalRow(sectionName,logicalRow);
      So now I have all the pieces needed to iterate through the count of active rows and delete each one without prompting the user for confirmation.

      My complete function is as follows:

      Code:
      function delAllRepeatSectionRows() {
      	//Get the number of rows in the repeating section
      	var repSectRows = {dialog.Object}._getRepeatingSectionRowCount('REPEATSECTION_1');
      	//If there are no rows in the repeating section, exit the routine
      	//If there are rows, delete them all
      	switch(repSectRows)	
      	{
      	case 0:
      		//There are no rows so we are done
      		break;
      	default:
      		//There is at least 1 row so we must delete it
      		for (var i=1; i<=repSectRows; i++)
      			{
      			//alert('i=' + i)
      			//The _getRepeatingSectionRowCount method was taken from the FireBug debug window
      			//and deals only with logical records (excluding deleted records)
      			//We must therefore convert i to it's physical row number before attempting to delete the record
      			
      			var phys_i = {dialog.Object}._repeatingSectionLogicalToPhysicalRow('REPEATSECTION_1',i);
      			
      			//delete the row
      			{dialog.Object}.deleteRepeatingSectionRow('REPEATSECTION_1',phys_i,true);
      				
      			}  //End for
      
      	} //End switch
      }

      Comment


        #4
        Re: Delete all repeating section rows when resetting a V11 dialog

        Excellent sleuthing Peter. I'll sure be referring to this post often... there's a ton of good stuff in here. Really good about the flagSilent. Your final solution, your explanation, and the links are really appreciated.

        Comment


          #5
          Re: Delete all repeating section rows when resetting a V11 dialog

          This is great code.
          I'm still experiencing a strange issue. If I load 20 rows, run your method, and load another 20 rows, the row count on the screen doesn't reset.
          These functions will take care of that.
          //{dialog.Object}.resetForm(false);
          //{Dialog.Object}.newRecord();

          However, although my row count starts back at 1, I can't go beyond the 5 default lines with which I started.

          Comment

          Working...
          X