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

Sort by Column Heading Is Lost If List Is Refreshed

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

    Sort by Column Heading Is Lost If List Is Refreshed

    I have a list that I am using to do bank reconciliations that is a list of the uncleared items. When user check marks that an item has cleared, I refresh the list with the List Control Action to Refresh Data (to get the current record to disappear from the list of uncleared items). The problem I have is that IF the user has clicked a column heading to sort the data in a way they need, the Refresh of the list loses their sort and goes back to the Order By sort that I have in my query for the list. I do want the list to first open based on my Order By, but then if a user has done their own column sort, I don't want them to lose their sort when the list is refreshed.

    I should also mention that I am using Group Breaks in the list to separate Deposits from Checks.

    Bottom line: I need to keep the user's current sort order when a list is refreshed. Any ideas?
    Last edited by kingcarol; 09-15-2016, 12:57 PM.
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    #2
    Re: Sort by Column Heading Is Lost If List Is Refreshed

    Here is just a quick thought. Store the current sort order to a variable then re-sort after the refresh. There may be a method to get the current sort order I'm not sure. It seems kind of the long around about way. Ultimately it should be done client side by surgically removing the row. While I am certain that can be done I have never tried that myself. You could very easily use a dynamic style, maybe gray it out or something. Besides don't they loose there place in the list when it is refreshed?

    I just leave the rows in the list and checked in my reconciliation form. I update the totals in the onclick of the cleared checkbox control. That way if a mistake is made it can be uncleared. I have a button that marks the cleared items reconciled when everything balances.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

    Comment


      #3
      Re: Sort by Column Heading Is Lost If List Is Refreshed

      You've given me some good things to think about, Frank. For now, I'd like to know if there is a way to capture the current sort order and resort after refresh. Does anyone know if there is a method for that? It almost seems like it could be an option for the list refresh method.
      Carol King
      Developer of Custom Homebuilders' Solutions (CHS)
      http://www.CHSBuilderSoftware.com

      Comment


        #4
        Re: Sort by Column Heading Is Lost If List Is Refreshed

        You've not stated your Alpha Version/Build but I'm guessing it's not current because I believe the current version maintains the sort order after a List Data refresh. Always good to list your version.

        However, you could try this. It's get's a bit hairy because you don't really know when to sort a List Control after you've refreshed it... because you don't know when that refresh is complete. This code looks after the simplest form of a List sort.

        In the UX client-side event onRenderComplete, set up some namespace vars we'll need...

        Code:
        {dialog.Object}.__listSort = {};
        {dialog.Object}.__listSort.orderField = false;
        In the button where you invoke the List refresh...

        Code:
        var lObj = {dialog.Object}.getControl('LIST1');
        var sOrder = lObj.order;
        if(sOrder){
        	for(var orderField in sOrder) {
        		if(sOrder.hasOwnProperty(orderField)) {
        			var orderDir = sOrder[orderField];
        			{dialog.Object}.__listSort = {};
        			{dialog.Object}.__listSort.orderField = orderField;
        			{dialog.Object}.__listSort.orderDir = orderDir;
        		}
        	}
        }else{
        	{dialog.Object}.__listSort.orderField = false;
        }	
        
        
        {dialog.object}.refreshListData('LIST1');
        Here, we are getting the List control object, and getting it's "order" property which is a name/value pair consisting of the column being sorted and it's direction. 1 for Asc, -1 for Desc. If no sort is set, then "order" is false.

        So... we test "order" to see if we need to sort. If so, we grab it's name/value pair and assign it to our namespace variables. Then we refresh the List.

        I'm not sure if there's a better way to tell when a List is finished refreshing. If someone as a tested method other that what follows, please post. For now, I'm using the List event, onListDraw. But... onListDraw fires before there's actually data in the List... so we need to get around that.

        Code:
        if(data.length > 0){
        	if({dialog.Object}.__listSort != undefined){
        		if({dialog.Object}.__listSort.orderField != false){
        		   var orderField = {dialog.Object}.__listSort.orderField;
        			var orderDir = {dialog.Object}.__listSort.orderDir;
        			var sortObj = '{' + '"' + orderField + '"' + ':' +  orderDir + '}';
        			var sortObj = JSON.parse(sortObj);
        			{dialog.Object}.__listSort.orderField = false;
        			this.setOrder(sortObj);
        		}
        	}
        }
        Here, we test for List data. If we have data, then check for our namespace vars. If they are in place, then get them. Build a string that with our sort details that we can turn into JSON and call the .setOrder method of the List. Since we're in a List event, we get to use 'this'.

        Finally, before we actually set the Order, we need to set our namespace var 'orderField' to false. This is because as soon as we call .setOrder() onListDraw fires again.

        Comment


          #5
          Re: Sort by Column Heading Is Lost If List Is Refreshed

          Thanks so much, David, for taking the time out for this. I did try to use your code but just couldn't get it to work (probably due to my own ignorance). But I dug a little deeper into the List Events and started playing with the AfterServerSideSort event and decided to make 2 hidden fields (USER_SORT_DIRECTION with a default of 0 and USER_SORT_COLUMN with a default of NONE) in my ux component to set both of them based on that events parameters for column and direction, and came up with the following. (I am only letting the user sort on 3 different columns in my list.)

          Code:
          var colSort = e.column
          var colDirection = e.direction
          
          if(colDirection == 'a'){
          	{dialog.object}.setValue('USER_SORT_DIRECTION',1);
          }
          
          if(colDirection == 'd'){
          	{dialog.object}.setValue('USER_SORT_DIRECTION',-1);
          }
          
          if(colSort == 1){
          	{dialog.object}.setValue('USER_SORT_COLUMN','GL_DATE');
          }
          if(colSort == 3){
          	{dialog.object}.setValue('USER_SORT_COLUMN','GL_DOCUMENT');
          }
          if(colSort == 6){
          	{dialog.object}.setValue('USER_SORT_COLUMN','TOTAL');
          }
          Then right after the list is refreshed using Action Javascript, I added an action with the following code and made sure to check mark to Run Actions Synchronously. I tried using the variables below in the line for the sortObj but that didn't work, so I had to hard code them and make 3 different If statements for my 3 columns.
          Code:
          var colHeading = {dialog.object}.getValue('USER_SORT_COLUMN');
          var colDirection = $u.s.toNum({dialog.object}.getValue('USER_SORT_DIRECTION'));
          
          if(colHeading == 'GL_DATE'){
          	if(colDirection == 1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'GL_DATE' : 1};
          		listObj.setOrder(sortObj);
          	}
          	if(colDirection == -1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'GL_DATE' : -1};
          		listObj.setOrder(sortObj);
          	}
          }
          
          if(colHeading == 'GL_DOCUMENT'){
          	if(colDirection == 1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'GL_DOCUMENT' : 1};
          		listObj.setOrder(sortObj);
          	}
          	if(colDirection == -1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'GL_DOCUMENT' : -1};
          		listObj.setOrder(sortObj);
          	}
          }
          
          if(colHeading == 'TOTAL'){
          	if(colDirection == 1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'TOTAL' : 1};
          		listObj.setOrder(sortObj);
          	}
          	if(colDirection == -1){
          		var listObj = {dialog.object}.getControl('LIST1');
          		var sortObj = {'TOTAL' : -1};
          		listObj.setOrder(sortObj);
          	}
          }
          This seems to be working well. It is only based on the last column sort, but that is going to be ok. ALSO, I have often noticed that sorting by clicking on column headings sometimes quits working after sorting a couple of columns, SO I went and added that last section of code to the AfterServerSideSort list event, and that is helping that issue, too!

          The version I am using is 2800-4476 from April of 2015 (I think). Everything has been working well for me using that version, so I haven't wanted to rock the boat ... :)

          Thank you all!! I think I have this solved.
          Carol King
          Developer of Custom Homebuilders' Solutions (CHS)
          http://www.CHSBuilderSoftware.com

          Comment


            #6
            Re: Sort by Column Heading Is Lost If List Is Refreshed

            You can try hiding the row with CSS. That way there is no need to refresh.

            Comment


              #7
              Re: Sort by Column Heading Is Lost If List Is Refreshed

              Originally posted by Michael1954 View Post
              You can try hiding the row with CSS. That way there is no need to refresh.
              Now that is a great idea. That would definitely surgically remove the row.
              Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

              Comment


                #8
                Re: Sort by Column Heading Is Lost If List Is Refreshed

                I probably don't want to hide the row in my case because i am using Group Breaks in the list and showing the summary total of the remaing records n each group.
                Last edited by kingcarol; 09-20-2016, 06:29 AM.
                Carol King
                Developer of Custom Homebuilders' Solutions (CHS)
                http://www.CHSBuilderSoftware.com

                Comment


                  #9
                  Re: Sort by Column Heading Is Lost If List Is Refreshed

                  I think the totals would still be correct if you are calculating client side.
                  Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                  Comment

                  Working...
                  X