Переглянути джерело

Bug fix: properly show which column the table is sorted on, even for external keys.
Enhancement: sort the non-selected columns alphabetically

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2210 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 12 роки тому
батько
коміт
75cf958527
1 змінених файлів з 13 додано та 3 видалено
  1. 13 3
      application/datatable.class.inc.php

+ 13 - 3
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;
+			}
 		}		
 	}