From a008107d3822e5257e728e10bc399ccf1f524234 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 25 Sep 2012 12:57:39 +0000 Subject: [PATCH] Bug fix: properly show which column the table is sorted on, even for external keys. Enhancement: sort the non-selected columns alphabetically SVN:trunk[2210] --- application/datatable.class.inc.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php index b6dd0bf42e..ba4f0d0e1f 100644 --- a/application/datatable.class.inc.php +++ b/application/datatable.class.inc.php @@ -457,6 +457,11 @@ EOF; { $aDefaultSort[] = "[".($iColOffset+$iPos).",".($bAscending ? '0' : '1')."]"; } + else if (($iPos = array_search(preg_replace('/_friendlyname$/', '', $sColCode), $aUniqueOrderedList)) !== false) + { + // if sorted on the friendly name of an external key, then consider it sorted on the column that shows the links + $aDefaultSort[] = "[".($iColOffset+$iPos).",".($bAscending ? '0' : '1')."]"; + } else if($sColCode == 'friendlyname' && $bViewLink) { $aDefaultSort[] = "[".($iColOffset).",".($bAscending ? '0' : '1')."]"; @@ -474,7 +479,6 @@ var oTable = $('#{$this->iListId} table.listResults'); oTable.tablesorter( { $sHeaders widgets: ['myZebra', 'truncatedList'] $sSortList} ).tablesorterPager({container: $('#pager{$this->iListId}'), totalRows:$iCount, size: $iPageSize, filter: '$sOQL', extra_params: '$sExtraParams', select_mode: '$sSelectModeJS', displayKey: $sDisplayKey, columns: $sJSColumns, class_aliases: $sJSClassAliases $sCssCount}); EOF ); - //if ($iNbPages == 1) if (false) { @@ -663,15 +667,21 @@ class DataTableSettings implements Serializable } $aList = MetaModel::ListAttributeDefs($sClass); - // Add the other (non visible ones) + // Add the other (non visible ones), sorted in alphabetical order + $aTempData = array(); foreach($aList as $sAttCode => $oAttDef) { if ( (!array_key_exists($sAttCode, $this->aColumns[$sAlias])) && (!$oAttDef instanceof AttributeLinkSet)) { $aFieldData = $this->GetFieldData($sAlias, $sAttCode, $oAttDef, false /* bChecked */, 'none'); - if ($aFieldData) $this->aColumns[$sAlias][$sAttCode] = $aFieldData; + if ($aFieldData) $aTempData[$aFieldData['label']] = $aFieldData; } } + ksort($aTempData); + foreach($aTempData as $sLabel => $aFieldData) + { + $this->aColumns[$sAlias][$aFieldData['code']] = $aFieldData; + } } }