diff --git a/packages/abc/st/demo/virtual.md b/packages/abc/st/demo/virtual.md index b1b9dceda..54aa7639e 100644 --- a/packages/abc/st/demo/virtual.md +++ b/packages/abc/st/demo/virtual.md @@ -55,11 +55,11 @@ export class DemoComponent implements AfterViewInit { ]; scrollToIndex(index: number): void { - this.st.cdkVirtualScrollViewport.scrollToIndex(index); + this.st.cdkVirtualScrollViewport?.scrollToIndex(index); } ngAfterViewInit(): void { - this.st.cdkVirtualScrollViewport.scrolledIndexChange.pipe(takeUntilDestroyed(this.destroy$)).subscribe(data => { + this.st.cdkVirtualScrollViewport?.scrolledIndexChange.pipe(takeUntilDestroyed(this.destroy$)).subscribe(data => { console.log('scroll index to', data); }); } diff --git a/packages/abc/st/st-data-source.ts b/packages/abc/st/st-data-source.ts index cc9a5afb0..51080aa7c 100644 --- a/packages/abc/st/st-data-source.ts +++ b/packages/abc/st/st-data-source.ts @@ -40,7 +40,7 @@ export interface STDataSourceOptions { pi: number; ps: number; paginator: boolean; - data: string | STData[] | Observable; + data?: string | STData[] | Observable; total: number; req: STReq; res: STRes; @@ -127,8 +127,8 @@ export class STDataSource { return deepCopy(ret); }) ); - } else if (Array.isArray(data)) { - data$ = of(data); + } else if (data == null || Array.isArray(data)) { + data$ = of(data ?? []); } else { // a cold observable data$ = data; diff --git a/packages/abc/st/st-td.component.html b/packages/abc/st/st-td.component.html index fd2d98af1..18d43d670 100644 --- a/packages/abc/st/st-td.component.html +++ b/packages/abc/st/st-td.component.html @@ -45,7 +45,7 @@ #render [ngTemplateOutlet]="c.__render!" [ngTemplateOutletContext]="{ $implicit: i, index: index, column: c }" -> +/>