Hello,
I'm trying to get an asynchronous excel export working in one of our grids but I consistently get an empty xsls file with only the collection headers. Data is properly being rendered in the grid, with filtering and pagination.
I've tried following the docs over here without success, here's my implementation:
Relevant parts in my component.ts:
01.
@Input() collection$: Observable<User[]>;
02.
03.
ngOnInit() {
04.
this
.allData =
this
.allData.bind(
this
);
05.
}
06.
07.
allData(): Observable<GridDataResult> {
08.
return
this
.collection$.pipe(
09.
map(users => ({ data: users, total: users.length }))
10.
);
11.
}
First thing I tried was to directly return this.collection$; but the behavior was the same: empty collection inside the excel file thus I tried returning an Observable<GridDataResult> instead with no success either.
Relevant parts in my component.html:
01.
<
kendo-grid
02.
[kendoGridBinding]="users$ | async"
03.
pageSize
=
"10"
04.
[pageable]="true"
05.
[filterable]="true"
06.
>
07.
<
ng-template
kendoGridToolbarTemplate>
08.
<
button
type
=
"button"
kendoGridExcelCommand
icon
=
"file-excel"
>
09.
Export to Excel
10.
</
button
>
11.
</
ng-template
>
12.
13.
<!-- columns -->
14.
15.
<
kendo-pager-prev-buttons
></
kendo-pager-prev-buttons
>
16.
<
kendo-pager-info
></
kendo-pager-info
>
17.
<
kendo-pager-next-buttons
></
kendo-pager-next-buttons
>
18.
<
kendo-pager-page-sizes
[pageSizes]="[5, 10, 40]"></
kendo-pager-page-sizes
>
19.
<
kendo-grid-excel
20.
fileName
=
"Users.xlsx"
21.
[fetchData]="allData"
22.
></
kendo-grid-excel
>
23.
</
kendo-grid
>
Thanks in advance.