N°3914 - Polishing: Lists - remove pagination when it is unnecessary

This commit is contained in:
acognet
2021-08-06 09:19:31 +02:00
parent d30871ac59
commit 0214243b63
3 changed files with 24 additions and 7 deletions

View File

@@ -167,8 +167,9 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
method: "post", method: "post",
pages: 1 // number of pages to cache pages: 1 // number of pages to cache
}), }),
createdRow: function( row, data, dataIndex ) { createdRow: function (row, data, dataIndex) {
if (data['@class'] !== undefined) { if (data['@class'] !== undefined)
{
$(row).addClass(data['@class']); $(row).addClass(data['@class']);
} }
}, },
@@ -176,8 +177,7 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
this.api().columns.adjust().draw(); this.api().columns.adjust().draw();
if (this.api().page.info().pages < 2) if (this.api().page.info().pages < 2)
{ {
this.parent().find('.dataTables_paginate').hide(); this.closest('.dataTables_wrapper').find('.dataTables_length').hide();
this.parent().find('.dataTables_length').hide();
} }
this.find('.ibo-dataTables--processing').remove(); this.find('.ibo-dataTables--processing').remove();
this.find('tbody').unblock(); this.find('tbody').unblock();

View File

@@ -41,6 +41,13 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
$(row).addClass(data['@class']); $(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')) %} {% if (oUIBlock.GetOption('bFullscreen')) %}

View File

@@ -58,15 +58,25 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
], ],
drawCallback: function () { drawCallback: function () {
// Hiding pagination if only one page // 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(); $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').hide();
} else { }
else
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show(); $(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; let oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oStaticTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){ const oStaticTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){
clearTimeout(oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout); clearTimeout(oStaticTable{{ sListIDForVarSuffix }}ResizeTimeout);