Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1 class="application-name">Application name</h1>
columnMode="force"
selectionType="single"
[cssClasses]="tableConfig.cssClasses"
[rows]="rows"
[rows]="rows()"
[columns]="[
{ name: 'Name', sortable: false },
{ name: 'Role', sortable: false },
Expand All @@ -65,10 +65,10 @@ <h1 class="application-name">Application name</h1>
[footerHeight]="tableConfig.footerHeight"
[rowHeight]="tableConfig.rowHeightSmall"
[externalPaging]="true"
[count]="page.totalElements"
[offset]="page.pageNumber"
[limit]="page.size"
[ghostLoadingIndicator]="isLoading > 0"
[count]="page().totalElements"
[offset]="page().pageNumber"
[limit]="page().size"
[ghostLoadingIndicator]="isLoading() > 0"
(page)="setPage($event)"
(siResizeObserver)="updateTableData($event)"
>
Expand All @@ -78,8 +78,8 @@ <h1 class="application-name">Application name</h1>
class="ms-auto"
forwardButtonText="forward"
backButtonText="back"
[currentPage]="page.pageNumber + 1"
[totalRowCount]="rows.length"
[currentPage]="page().pageNumber + 1"
[totalRowCount]="rows().length"
(currentPageChange)="table.onFooterPage({ page: $event })"
/>
</ng-template>
Expand Down
37 changes: 19 additions & 18 deletions src/app/examples/si-layouts/content-full-layout-full-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Siemens 2016 - 2025
* SPDX-License-Identifier: MIT
*/
import { Component, inject, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
import { RouterLink } from '@angular/router';
import {
SiAccountDetailsComponent,
Expand Down Expand Up @@ -47,10 +47,13 @@ import { CorporateEmployee, DataService, Page, PageRequest } from '../datatable/
SiHeaderLogoDirective
],
templateUrl: './content-full-layout-full-scroll.html',
providers: [DataService]
providers: [DataService],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SampleComponent implements OnInit {
menuItems: NavbarVerticalItem[] = [
private readonly dataService = inject(DataService);
protected readonly tableConfig = SI_DATATABLE_CONFIG;
protected readonly menuItems: NavbarVerticalItem[] = [
{
type: 'group',
label: 'Home',
Expand All @@ -73,13 +76,11 @@ export class SampleComponent implements OnInit {
{ type: 'router-link', label: 'Energy & Operations', routerLink: 'energy' },
{ type: 'router-link', label: 'Test Coverage', routerLink: 'coverage' }
];
tableConfig = SI_DATATABLE_CONFIG;
pageRequest?: PageRequest;
page = new Page();
rows = new Array<CorporateEmployee>();
isLoading = 0;

private dataService = inject(DataService);
protected pageRequest?: PageRequest;
protected readonly page = signal(new Page());
protected readonly rows = signal<CorporateEmployee[]>([]);
protected readonly isLoading = signal(0);

ngOnInit(): void {
// timeout needed to work in the iFrame in the docs
Expand All @@ -96,38 +97,38 @@ export class SampleComponent implements OnInit {
this.pageRequest?.pageSize !== pageRequest.pageSize
) {
this.pageRequest = pageRequest;
this.isLoading++;
this.isLoading.update(value => value + 1);
// We reload the data when the page number or page size changes.
// During this time, we want to show the ghost loading indicator.
// To make sure no data is presented. We set the rows in the table
// to an empty array.
this.rows = [];
this.rows.set([]);
this.dataService.getResults(pageRequest).subscribe(pagedData => {
this.isLoading--;
this.isLoading.update(value => value - 1);
// Make sure we set the date to the latest page request.
if (
this.pageRequest?.offset === pageRequest.offset &&
this.pageRequest?.pageSize === pageRequest.pageSize
) {
this.page = pagedData.page;
this.rows = pagedData.data;
this.page.set(pagedData.page);
this.rows.set(pagedData.data);
}
});
}
}

updateTableData(dimensions?: ElementDimensions): void {
protected updateTableData(dimensions?: ElementDimensions): void {
if (!dimensions) {
return;
}

const bodyHeight =
dimensions.height - SI_DATATABLE_CONFIG.headerHeight - SI_DATATABLE_CONFIG.footerHeight;
const pageSize = Math.floor(bodyHeight / SI_DATATABLE_CONFIG.rowHeightSmall);
this.page.size = pageSize;
this.page.update(value => ({ ...value, size: pageSize }));
this.setPage({
offset: this.page.pageNumber,
pageSize: this.page.size
offset: this.page().pageNumber,
pageSize: this.page().size
});
}
}
Loading