Page 1 of 7 12345 ... LastLast
Results 1 to 10 of 61

Thread: Sort order descending problem FIXED!!!

  1. #1
    MrPresley is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    28

    Default Sort order descending problem FIXED!!!

    This has been driving me nuts for the last couple of days. I have found numerous posts and bugs regarding the issue with no resolutions. I spent four hours this morning trying to find out how to fix the following problem:

    Sugar would always default to ascending order on most items in list view, others it would toggle between ascending and descending everytime you refreshed the view or left and came back. This created quite a nuisance as you couldn't keep your latest cases up at the top and your account/contact history items were sorting ascending causing the oldest items to show first instead of the latest items at top. Sugar was functioning the opposite to the way it should.

    Solution:
    Simple as Pumpkin Pie. Edit one word of code in include/listview/listview.php around line 773 where it says the following:

    $this->sort_order = 'asc';

    Change 'asc' to 'desc'

    That's it!
    Now, Sugar has a thing where it remembers the last sort column you clicked on. So just click the column you want to sort by and it will always sort by that column in descending order from now on, until and unless you click on it or another column again.

    Hope this helps others, it was a big nagging issue for me.

    David Faria

  2. #2
    manoj is offline Sugar Community Member
    Join Date
    Sep 2005
    Posts
    495

    Default Re: Sort order descending problem FIXED!!!

    Quote Originally Posted by MrPresley
    This has been driving me nuts for the last couple of days. I have found numerous posts and bugs regarding the issue with no resolutions. I spent four hours this morning trying to find out how to fix the following problem:

    Sugar would always default to ascending order on most items in list view, others it would toggle between ascending and descending everytime you refreshed the view or left and came back. This created quite a nuisance as you couldn't keep your latest cases up at the top and your account/contact history items were sorting ascending causing the oldest items to show first instead of the latest items at top. Sugar was functioning the opposite to the way it should.

    Solution:
    Simple as Pumpkin Pie. Edit one word of code in include/listview/listview.php around line 773 where it says the following:

    $this->sort_order = 'asc';

    Change 'asc' to 'desc'

    That's it!
    Now, Sugar has a thing where it remembers the last sort column you clicked on. So just click the column you want to sort by and it will always sort by that column in descending order from now on, until and unless you click on it or another column again.

    Hope this helps others, it was a big nagging issue for me.

    David Faria

    Hi David,

    We are working on this issue and will soon communicate the design approach to the team. Please stay tuned and provide us your valuable feedback.

    Thanks
    Manoj

  3. #3
    jef_b is offline Junior Member
    Join Date
    Jan 2006
    Posts
    1

    Default Re: Sort order descending problem FIXED!!!

    I have tried this fix. Works but seems to whack all the buttons for sorting all the displayed column buttons.

    Any update on a fix?

  4. #4
    doctorlard is offline Sugar Community Member
    Join Date
    Mar 2006
    Posts
    26

    Default Re: Sort order descending problem FIXED!!!?

    I am also chewing on this. The highlighted code above in include/Listview/ListView.php at line 773 is looking in $_REQUEST for details that aren't there. At that point in the call stack there are a bunch of interesting and relevant looking keys in $_SESSION which is probably what they meant.

    As it stands at the moment, none of the code at the top of the processUnionBeans() function that tries to process 'sort_order' will work at all since some of it isn't in either $_REQUEST or $_SESSION...

  5. #5
    doctorlard is offline Sugar Community Member
    Join Date
    Mar 2006
    Posts
    26

    Lightbulb Re: Sort order descending problem FIXED!!!

    Ok, I'm using Sugar version 4.2.0a and the problem is the code in include/ListView/ListView.php in the function processUnionBeans() which is at line 772 or so. This code is sloppy as hell - it isn't indented consistently, contains a duplicate if statement (let's check twice, just in case!), and doesn't follow Sugar's stated coding standards. I'd love to submit a patch but in the meantime this fixed the problem.

    Starting after $response = array(); at line 778, replace this:

    Code:
    if(isset($_REQUEST['sort_order'])) {
    	$this->sort_order = $_REQUEST['sort_order'];
    }	
    	$this->sort_order = 'asc';
    if(isset($_REQUEST['sort_order'])) {
    	$this->sort_order = $_REQUEST['sort_order'];
    }	
    else if(isset($_REQUEST['subpanel'])){
    	 if(isset($_SESSION['last_sub' .$this->subpanel_module. '_url']) && $_SESSION['last_sub' .$this->subpanel_module. '_url'] == $this->getBaseURL('CELL')) {
    		if(isset($_SESSION['last_sub' .$this->subpanel_module. '_order']) && $_SESSION['last_sub' .$this->subpanel_module. '_order'] == 'asc') {
    			$this->sort_order = 'desc';
    		} 
    	}
    	else if(isset($subpanel_def->_instance_properties['sort_order'])) {
    		$this->sort_order = $subpanel_def->_instance_properties['sort_order'];
    	}
    }
    with this:

    Code:
    $this->sort_order = 'asc';
    
    if (isset($_SESSION['sort_order'])) {
    	$this->sort_order = $_SESSION['sort_order']; #TODO: it isn't in _SESSION either. I wonder where 'sort_order' is? The hunt continues.
    }
    else if (isset($this->subpanel_module) and $this->subpanel_module != '') {
    	if (isset($_SESSION['last_sub' .$this->subpanel_module. '_url']) and $_SESSION['last_sub' .$this->subpanel_module. '_url'] == $this->getBaseURL('CELL')) {
    		if (isset($_SESSION['last_sub' .$this->subpanel_module. '_order']) and $_SESSION['last_sub' .$this->subpanel_module. '_order'] == 'asc') {
    			$this->sort_order = 'desc';
    		}
    	}
    	else if (isset($subpanel_def->_instance_properties['sort_order'])) {
    		$this->sort_order = $subpanel_def->_instance_properties['sort_order'];
    	}
    }

  6. #6
    george_bbch is offline Sugar Community Member
    Join Date
    Jan 2006
    Location
    Switzerland
    Posts
    349

    Default Re: Sort order descending problem FIXED!!!

    Many thanks, doctorlard, it works great!!!!

  7. #7
    phatpixel is offline Sugar Community Member
    Join Date
    Apr 2005
    Posts
    30

    Default Re: Sort order descending problem FIXED!!!

    Whilst we're on the subject of sort order... am I the only one to notice that the arrows indicating sort order point in the wrong direction in SugarCRM?

    Ascending order should point UP, and descending order should point DOWN. This is both logical and consistent with the way it's done everywhere else.

  8. #8
    maxcrm is offline Sugar Community Member
    Join Date
    Jan 2006
    Posts
    14

    Default Re: Sort order descending problem FIXED!!!

    Quote Originally Posted by doctorlard
    Ok, I'm using Sugar version 4.2.0a and the problem is the code in include/ListView/ListView.php in the function processUnionBeans() which is at line 772 or so. This code is sloppy as hell - it isn't indented consistently, contains a duplicate if statement (let's check twice, just in case!), and doesn't follow Sugar's stated coding standards. I'd love to submit a patch but in the meantime this fixed the problem.
    [/code]
    I tried this but didn't work for me! when i click on the module tab, the sort order changes for the column i am sorting by! where is the session information saved? do i need to clear all my session data so my preference would be saved correctly? where and how do i do that?

    4.2.0d is my installation

    Thank you very much for all your help.

    Max

  9. #9
    EdSawyer is offline Sugar Community Member
    Join Date
    Jan 2006
    Posts
    35

    Default Re: Sort order descending problem FIXED!!!

    I tried this fix above from doctorlard (Thanks for the efforts on this bug!), but alas it's not working for me. Just reloading the page (list view of Leads for example) constantly toggles the asc or desc of the sort order. Can't seem to fix it. Going to detail page and back again reverses the sort order. (argh!!). We are using 4.2.0a pro version.

    any ideas? I've tried everything I have seen in the forums so far but none of it fixes the toggling of sort order which comes from reloading a page or going to detailview and back again to list view.

    It seems inconsistent,... sometimes the sort doesn't get screwed up and I think it's fixed, but then it will start toggling again. Maddening!

    -Ed

  10. #10
    maxcrm is offline Sugar Community Member
    Join Date
    Jan 2006
    Posts
    14

    Default Re: Sort order descending problem FIXED!!!

    Quote Originally Posted by EdSawyer
    I tried this fix above from doctorlard (Thanks for the efforts on this bug!), but alas it's not working for me. Just reloading the page (list view of Leads for example) constantly toggles the asc or desc of the sort order. Can't seem to fix it. Going to detail page and back again reverses the sort order. (argh!!). We are using 4.2.0a pro version.

    any ideas? I've tried everything I have seen in the forums so far but none of it fixes the toggling of sort order which comes from reloading a page or going to detailview and back again to list view.

    It seems inconsistent,... sometimes the sort doesn't get screwed up and I think it's fixed, but then it will start toggling again. Maddening!

    -Ed
    i agree with you Ed! this fix is not working! seems like lots of fixes are needed, but this seem to be very important! there is nothing like an upset sales person! the best thing to do now is to force the order - hardcode it!

    Max

Page 1 of 7 12345 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •