Skip to content

Commit 84e1fa9

Browse files
committed
#114 fix number of items shown
1 parent 76e77aa commit 84e1fa9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/lib/components/Table/TableContent.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
// Creating the table columns
293293
const createdTableColumns = table.createColumns(tableColumns);
294294
// Creating the table view model
295-
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
295+
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates, rows } =
296296
table.createViewModel(createdTableColumns);
297297
// Extracting filterValue to bind it for the search input and search immediately on input
298298
const { filterValue } = pluginStates.tableFilter;
@@ -691,6 +691,7 @@
691691
/>
692692
{:else}
693693
<TablePagination
694+
itemCount={$rows.length}
694695
pageConfig={pluginStates.page}
695696
{pageSizes}
696697
id={tableId}

src/lib/components/Table/TablePagination.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
} from '@fortawesome/free-solid-svg-icons';
1010
import { ListBox, ListBoxItem, popup, type PopupSettings } from '@skeletonlabs/skeleton';
1111
12+
export let itemCount;
1213
export let pageConfig;
1314
export let pageSizes;
1415
export let pageIndexStringType;
1516
export let id;
16-
17+
1718
let indexInformation = '';
1819
1920
const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
@@ -49,9 +50,10 @@
4950
if (pageIndexStringType === 'pages') {
5051
return $pageCount > 0 ? `Page ${$pageIndex + 1} of ${$pageCount}` : 'No pages';
5152
} else {
52-
return `Displaying items ${$pageIndex * $pageSize + 1} - ${($pageIndex + 1) * $pageSize} of ${
53-
$pageCount * $pageSize
54-
}`;
53+
return itemCount === 0 ? 'No items' : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
54+
($pageIndex + 1) * $pageSize,
55+
itemCount
56+
)} of ${Math.min($pageCount * $pageSize, itemCount)}`;
5557
}
5658
};
5759

0 commit comments

Comments
 (0)