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]
This commit is contained in:
Denis Flaven
2012-09-25 12:57:39 +00:00
parent dc4bfc6b30
commit a008107d38

View File

@@ -457,6 +457,11 @@ EOF;
{ {
$aDefaultSort[] = "[".($iColOffset+$iPos).",".($bAscending ? '0' : '1')."]"; $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) else if($sColCode == 'friendlyname' && $bViewLink)
{ {
$aDefaultSort[] = "[".($iColOffset).",".($bAscending ? '0' : '1')."]"; $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}); 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 EOF
); );
//if ($iNbPages == 1) //if ($iNbPages == 1)
if (false) if (false)
{ {
@@ -663,15 +667,21 @@ class DataTableSettings implements Serializable
} }
$aList = MetaModel::ListAttributeDefs($sClass); $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) foreach($aList as $sAttCode => $oAttDef)
{ {
if ( (!array_key_exists($sAttCode, $this->aColumns[$sAlias])) && (!$oAttDef instanceof AttributeLinkSet)) if ( (!array_key_exists($sAttCode, $this->aColumns[$sAlias])) && (!$oAttDef instanceof AttributeLinkSet))
{ {
$aFieldData = $this->GetFieldData($sAlias, $sAttCode, $oAttDef, false /* bChecked */, 'none'); $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;
}
} }
} }