N°3914 Fix lists header and data being misaligned when resizing them

This commit is contained in:
Stephen Abello
2021-05-27 09:59:06 +02:00
committed by Eric
parent fe8e71fb40
commit b280b28450
3 changed files with 42 additions and 5 deletions

View File

@@ -329,4 +329,15 @@ if ($('#datatable_dlg_{{ oUIBlock.GetId() }}').hasClass('itop-datatable')) {
$('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings('destroy');
}
$('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings($aOptions);
$('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings($aOptions);
if(window.ResizeObserver){
let oTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){
clearTimeout(oTable{{ sListIDForVarSuffix }}ResizeTimeout);
oTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function(){
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
}, 120);
});
oTable{{ sListIDForVarSuffix }}Resize.observe($('#{{ oUIBlock.GetId() }}')[0]);
}

View File

@@ -1,4 +1,7 @@
var table{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{% set sListId = oUIBlock.GetId() %}
{% set sListIDForVarSuffix = ('' ~ sListId)|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
var table{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
language: {
emptyTable: "{{ 'UI:Message:EmptyList:UseAdd'|dict_s }}"
},
@@ -23,5 +26,16 @@ var table{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_
{% endif %}
});
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible')) {
table{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }}.columns.adjust().draw();
table{{ sListIDForVarSuffix }}.columns.adjust().draw();
}
if(window.ResizeObserver){
let oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){
clearTimeout(oFromTable{{ sListIDForVarSuffix }}ResizeTimeout);
oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function(){
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
}, 120);
});
oFromTable{{ sListIDForVarSuffix }}Resize.observe($('#{{ oUIBlock.GetId() }}')[0]);
}

View File

@@ -1,6 +1,7 @@
{# @copyright Copyright (C) 2010-2021 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% set sListId = oUIBlock.GetId() %}
{% set sListIDForVarSuffix = ('' ~ sListId)|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
{% if oUIBlock.GetOption("iPageSize") is not empty %}
{% set iPageSize = oUIBlock.GetOption("iPageSize") %}
{% else %}
@@ -58,4 +59,15 @@ $('#{{ oUIBlock.GetId() }}').DataTable({
},
{% endfor %}
]
});
});
if(window.ResizeObserver){
let oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oStaticTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){
clearTimeout(oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout);
oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function(){
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
}, 120);
});
oStaticTable{{ sListIDForVarSuffix }}Resize.observe($('#{{ oUIBlock.GetId() }}')[0]);
}