This is a migrated thread and some comments may be shown as answers.

Exporting an aggregate, pagable Grid

2 Answers 391 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bhavin
Top achievements
Rank 1
bhavin asked on 21 Jun 2019, 02:55 PM

Can u share an example for the grid which uses aggregate, is page able and has export excel feature. 
In examples provided u guys use 

.get(`${this.BASE_URL}${tableName}?${queryStr}`)  

but usually for aggregates I am using something like 

return this.http.get<Array<CollectorGoalSummaryModel>>('/api/report')
.subscribe((data)=>{
let aggregates: any[] = [

{field: 'totalCash', aggregate: 'sum'}

  ];
this.store.collectorGoalSummary = data;
this.store.totals = aggregateBy(data, aggregates)

this.store.currentPageStats = {
data: this.store.collectorGoalSummary.slice(skip, skip + pageSize),
total: this.store.collectorGoalSummary.length
}
})

 

Having a hard time trying to put the Export grid with aggregates in it

2 Answers, 1 is accepted

Sort by
0
bhavin
Top achievements
Rank 1
answered on 24 Jun 2019, 12:20 PM
Even if your able to put the export it does not take in the entire data set, it only takes the rows which are currently displayed. I am unable to do it the way you have put on the website however, as I am bound with the structure mentioned above
0
Dimiter Topalov
Telerik team
answered on 25 Jun 2019, 01:27 PM
Hi Bhavin,

In scenarios, involving asynchronous data retrieval, you can return the Observable from the service directly and bind the fetchData input to it so that the Observable will be automatically subscribed to via the async pipe in the template, and the custom set of items will be properly exported, e.g.:

https://www.telerik.com/kendo-angular-ui/components/grid/export/excel-export/#toc-exporting-specific-data // the second example

Here is an updated example modified to feature grouping and aggregates:

https://stackblitz.com/edit/angular-xqowva-mkc36e?file=app/app.component.ts

Some of the additional processing in the example is added to address the fact that the specific remote OData service used does not support server-side grouping. It is the remote demo service specific behavior to return a maximum of 20 items too (this is why only 20 items are exported instead of all of them), but the same principles will apply.

Regardless of whether the fetchData function returns the ExcelExportData object directly, or wrapped in a promise or an Observable, it should contain both all grouped and otherwise processed data items, and the group and aggregates configuration:

https://www.telerik.com/kendo-angular-ui/components/excelexport/api/ExcelExportData/

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
bhavin
Top achievements
Rank 1
Answers by
bhavin
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Share this question
or