Skip to content
Snippets Groups Projects
Commit 9a8059cf authored by Alan Bell's avatar Alan Bell
Browse files

if the preference LISTVIEW_DEFAULT_SORTING is specified then use it for list...

if the preference LISTVIEW_DEFAULT_SORTING is specified then use it for list views and related lists
parent e46fa610
No related branches found
No related tags found
1 merge request!34Fix default sort ref #110
Loading
  • Alan Lord @lord_alan ·
    Contributor

    @uma.s Do you know why this patch was removed when the v7 code was dropped in? Re-introducing this would be very helpful for some of my customers.

  • Uma @uma.s ·
    Guest

    @lord_alan I noticed that this change was introduced 5 years back, where we have introduced the api getOrderBy() in core file data/CRMEntity.php which checks through the performance settings for default sorting and returns.

  • Alan Lord @lord_alan ·
    Contributor

    @uma.s Thanks - but the getOrderBy() in CRMEntity.php doesn't seem to work at all! I was looking at it this morning. In my test system, none of the lists or related lists seem to follow the $focus->default_order_by when LISTVIEW_DEFAULT_SORTING is enabled.

    If I make a few changes (similar to this patch) to the above two files however then I can get sorting to work as expected:

    ListView Model:

    		} else if(empty($orderBy) && empty($sortOrder) && $moduleName != "Users") {
                if (PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
                    $orderBy = $moduleFocus->default_order_by;
                    $qualifiedOrderBy = $orderBy;
                    $orderByField = $moduleModel->getFieldByColumn($orderBy);
                    if($orderByField) {
                        $qualifiedOrderBy = $moduleModel->getOrderBySql($qualifiedOrderBy);
                        $sortOrder = $moduleFocus->default_sort_order;
        				$listQuery .= ' ORDER BY '.$qualifiedOrderBy.' '.$sortOrder;
        			} else {
                        $listQuery .= ' ORDER BY vtiger_crmentity.modifiedtime DESC';    			
        			}
                } else {
    			    //List view will be displayed on recently created/modified records
    			    $listQuery .= ' ORDER BY vtiger_crmentity.modifiedtime DESC';
    			}
    		}

    and RelationListView model:

    		} else if(!$orderBy & PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
                $entityModule = CRMEntity::getInstance($relationModuleName);
                $orderBy = $entityModule->default_order_by;
    			$qualifiedOrderBy = $orderBy;
                $orderByField = $relationModule->getFieldByColumn($orderBy);
                if($orderByField) {
                    $qualifiedOrderBy = $relationModule->getOrderBySql($qualifiedOrderBy);
                    $sortOrder = $entityModule->default_sort_order;
                    $query .= ' ORDER BY '.$qualifiedOrderBy.' '.$sortOrder;
                } else {
                    $query .= ' ORDER BY vtiger_crmentity.modifiedtime DESC';
                }
    		} else if($relationModuleName == 'HelpDesk' && empty($orderBy) && empty($sortOrder) && $moduleName != "Users") {
    			$query .= ' ORDER BY vtiger_crmentity.modifiedtime DESC';
    		}
  • Uma @uma.s ·
    Guest

    @lord_alan Thanks! for the patch, will consider this in the pipeline and make it to next release.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment