Skip to content

Commit

Permalink
[5.3] MSTR-320: Fix table paging position and value when there are no…
Browse files Browse the repository at this point in the history
… rows (#1237)
  • Loading branch information
guillegr123 committed Aug 19, 2024
1 parent 13d15a8 commit 5bc8202
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/apps/core/views/monster-table-paging.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</li>
</ul>
<div class="divider"></div>
<span class="label label-default">1-{{rowCount}} of {{rowCount}}</span>
<span class="label label-default">{{#compare rowCount "===" 0}}0{{else}}1{{/compare}}-{{rowCount}} of {{rowCount}}</span>
</div>
</td>
</td>
</tr>
14 changes: 11 additions & 3 deletions src/js/lib/monster.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2868,15 +2868,23 @@ define(function(require) {
// If we gave a selector with many table, we need to add the component to each table, so we need to loop thru each table included in the jquery selector
$.each(table, function(k, singleTable) {
var $singleTable = $(singleTable),
$tablePaging = $singleTable.find('.footable-paging td');
$tablePaging = $singleTable.find('.footable-paging td'),
rowCount = footable.get($singleTable).rows.all.length;

if ($tablePaging.length === 0) {
var cols = 0;

$singleTable.find('tbody > tr:first > td').each(function() {
var colspanStr = $(this).attr('colspan');
cols += (_.parseInt(colspanStr) || 1);
});

$singleTable.find('tfoot').append(
$(monster.template(
monster.apps.core, 'monster-table-paging',
{
cols: $singleTable.find('tbody > tr:first > td').length,
rowCount: footable.get($singleTable).rows.all.length
cols: cols,
rowCount: rowCount
}
))
);
Expand Down

0 comments on commit 5bc8202

Please sign in to comment.