diff --git a/sources/application/UI/Base/Component/DataTable/DataTableSettings.php b/sources/application/UI/Base/Component/DataTable/DataTableSettings.php index b94eee9e4..178f44e47 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableSettings.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableSettings.php @@ -136,8 +136,9 @@ class DataTableSettings implements Serializable if (array_key_exists($sNormalizedFName, $aSortOrder)) { $sSort = $aSortOrder[$sNormalizedFName] ? 'asc' : 'desc'; } + $aColumns[$sAlias]['_key_'] = $oSettings->GetFieldData($sAlias, '_key_', null, true /* bChecked */, $sSort); } - $aColumns[$sAlias]['_key_'] = $oSettings->GetFieldData($sAlias, '_key_', null, true /* bChecked */, "none"); + foreach ($aList as $sAttCode) { $sSort = 'none'; if (array_key_exists($sAttCode, $aSortOrder)) { diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 2f8bc2fb5..c80889ebd 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -285,7 +285,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory $oSet->SetLimit($oCustomSettings->iDefaultPageSize); } - if (sizeof($oCustomSettings->aColumns) == 0) + if (count($oCustomSettings->aColumns) == 0) { $oCustomSettings->aColumns = $oDefaultSettings->aColumns; $oCustomSettings->aSortOrder = $oDefaultSettings->aSortOrder; @@ -324,6 +324,10 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory $aSortOrder[$sAlias.$sCode] = ($aData['sort'] == 'asc'); // true for ascending, false for descending $aSortDatable=[$iIndexColumn,$aData['sort']]; } + elseif (isset($oCustomSettings->aSortOrder[$sAttCode])){ + $aSortOrder[$sAlias.$sCode] = $oCustomSettings->aSortOrder[$sAttCode]; // true for ascending, false for descending + } + if ($aData['checked']) { if ($sAttCode == '_key_') { if ($bViewLink) { diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index 8bbee1c9f..3ff05db0b 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -46,7 +46,7 @@ var oTable{{ sListIfForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ {% endif %} lengthMenu: [[ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, -1], [ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, "{{ 'UI:Datatables:Language:DisplayLength:All'|dict_s }}"]], dom: "<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>t<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>", - {% if( oUIBlock.GetOptions("sort")[0] is defined ) %} + {% if( oUIBlock.GetOption("sort")[0] is defined ) %} order: [[{{ oUIBlock.GetOptions()["sort"][0] }}, '{{ oUIBlock.GetOptions()["sort"][1] }}']], {% else %} order: [],