diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index 26fbcc6f4..af242aadc 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -167,8 +167,9 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ method: "post", pages: 1 // number of pages to cache }), - createdRow: function( row, data, dataIndex ) { - if (data['@class'] !== undefined) { + createdRow: function (row, data, dataIndex) { + if (data['@class'] !== undefined) + { $(row).addClass(data['@class']); } }, @@ -176,8 +177,7 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ this.api().columns.adjust().draw(); if (this.api().page.info().pages < 2) { - this.parent().find('.dataTables_paginate').hide(); - this.parent().find('.dataTables_length').hide(); + this.closest('.dataTables_wrapper').find('.dataTables_length').hide(); } this.find('.ibo-dataTables--processing').remove(); this.find('tbody').unblock(); diff --git a/templates/base/components/datatable/static/formtable/layout.ready.js.twig b/templates/base/components/datatable/static/formtable/layout.ready.js.twig index 2b2991537..3cac4a04f 100644 --- a/templates/base/components/datatable/static/formtable/layout.ready.js.twig +++ b/templates/base/components/datatable/static/formtable/layout.ready.js.twig @@ -41,6 +41,13 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ $(row).addClass(data['@class']); } }, + + initComplete: function () { + if (this.api().page.info().pages < 2) + { + this.closest('.dataTables_wrapper').find('.dataTables_length').hide(); + } + }, }); {% if (oUIBlock.GetOption('bFullscreen')) %} diff --git a/templates/base/components/datatable/static/layout.ready.js.twig b/templates/base/components/datatable/static/layout.ready.js.twig index 92bc6da4d..51fa96a67 100644 --- a/templates/base/components/datatable/static/layout.ready.js.twig +++ b/templates/base/components/datatable/static/layout.ready.js.twig @@ -58,15 +58,25 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ ], drawCallback: function () { // Hiding pagination if only one page - if ($(this).closest('.dataTables_wrapper').find('.dataTables_paginate:last .paginate_button:not(.previous):not(.next)').length < 2) { + if ($(this).closest('.dataTables_wrapper').find('.dataTables_paginate:last .paginate_button:not(.previous):not(.next)').length < 2) + { $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').hide(); - } else { + } + else + { $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show(); } + }, + initComplete: function () { + if (this.api().page.info().pages < 2) + { + this.closest('.dataTables_wrapper').find('.dataTables_length').hide(); + } } }); -if(window.ResizeObserver){ +if (window.ResizeObserver) +{ let oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout = null; const oStaticTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){ clearTimeout(oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout);