WIP Sort working on all types but client-side

This commit is contained in:
Molkobain
2026-05-08 11:07:33 +02:00
parent 55444eaacd
commit ba405e64d2
2 changed files with 10 additions and 3 deletions

View File

@@ -196,9 +196,12 @@ var iTopDataTableTreeGrouping = (function ($) {
// Friendly name is always loaded; it sorts better than the numeric DB id
return sMData.replace(/\/_key_$/, '/friendlyname');
}
// External key attributes store a numeric ID in /raw use /friendlyname instead
// External/hierarchical key attributes store a numeric ID in "/raw", use "/friendlyname" instead.
// AttributeHierarchicalKey extends AttributeExternalKey but its PHP class name does not contain
// "ExternalKey", hence the separate check.
if (oCol.metadata && typeof oCol.metadata.attribute_type === 'string' &&
oCol.metadata.attribute_type.indexOf('ExternalKey') !== -1) {
(oCol.metadata.attribute_type.indexOf('ExternalKey') !== -1 ||
oCol.metadata.attribute_type.indexOf('HierarchicalKey') !== -1)) {
return sMData + '/friendlyname';
}
return sMData + '/raw';

View File

@@ -115,10 +115,14 @@ class AjaxRenderController
foreach ($aColumnsLoad[$sAlias] as $sAttCode) {
$aObj[$sAlias."/".$sAttCode] = $aObject[$sAlias]->GetAsHTML($sAttCode);
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
// Expose the friendly name of external/hierarchical keys so JS can sort by label
if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
$aObj[$sAlias."/".$sAttCode."/friendlyname"] = $aObject[$sAlias]->Get($sAttCode.'_friendlyname');
}
$bExcludeRawValue = false;
// Only retrieve raw (stored) value for simple fields
foreach (cmdbAbstractObject::GetAttDefClassesToExcludeFromMarkupMetadataRawValue() as $sAttDefClassToExclude) {
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (is_a($oAttDef, $sAttDefClassToExclude, true)) {
$bExcludeRawValue = true;
break;