Grid Cusom DataSource is not wokring

I'm using https://ej2.syncfusion.com/angular/documentation/grid/pdf-export/#custom-data-source but is not working in last version.

There is that eror.
TypeError: Cannot read property 'records' of undefined

his.pdfExportProperties.dataSource = {
'items' : dataSource as Object[]
}


To export but there aren't value, Only, there are column.

Also When I click exporting, That e-aggregates field repeats



1 Reply

MS Manivel Sellamuthu Syncfusion Team May 18, 2020 09:17 AM UTC

Hi kenan, 

Greetings from Syncfusion support. 

Query: There is that error. TypeError: Cannot read property 'records' of undefined. 
 
Before validating this issue on our end, we need some clarifications , which will be helpful to validate and provide a better suggestion as soon as possible. 

  1. Share your complete Grid code
  2. Please explain this code, since we do not have property named items in pdfExportproperties this.pdfExportProperties.dataSource = {
            'items' : dataSource as Object[] 
         
  1. but is not working in last version – From this code we suspect that the issue occurs in the latest version only,
if so please share the version details the current version, and previous version you have used  
  
Query: To export but there aren't value, Only, there are column.Also When I click exporting, That e-aggregates field repeats 
 
It is a known scenario from our end , the angular Ng-template has some technical limitation while compiling the Ng-template.  So it is not feasible to add fix in our source (due to technical limitation while compiling the ng-template).So we suggest you to use the TypeScript way of rendering the aggregates in Grid(as suggested in the below code example), 

[App.component.html] 
<div class="control-section"> 
    <ejs-grid #grid [dataSource]='data'  [allowGrouping]="true" [groupSettings]="groupSettings" allowPaging='true' height=400  
[pageSettings]='pageSettings' [aggregates]='aggreagtes'  [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' 
                [allowExcelExport]='true' [allowPdfExport]='true'> 
        <e-columns> 
             . . . 
        </e-columns> 
    </ejs-grid> 
</div> 
[App.component.ts] 
export class AppComponent { 
    public aggreagtes: Object; 
    public pdfExportPrperties: Object = {}; 
    @ViewChild('grid', {statictrue}) 
    public grid: GridComponent; 
    public groupSettings: { [x: string]: Object } = { showDropArea: false, columns: ['ShipCountry'] }; 
 
    public ngOnInit(): void { 
        this.data = orderDetails; 
        this.toolbar = ['PdfExport']; 
        this.pageSettings = { pageCount: 5 }; 
        this.aggreagtes = [{ 
           columns: [{ 
                    type'Sum', 
                    field: 'OrderID', 
                    groupFooterTemplate: 'Total units: ${Sum}' 
                }, 
                { 
                    type'Max', 
                    field: 'Freight', 
                    groupCaptionTemplate: 'Maximum: ${Max}' 
                }] 
        }]; 
    } 
 
    toolbarClick(args: ClickEventArgs): void { 
        switch (args.item.text) { 
            case 'PDF Export': 
            this.grid.pdfExport(); 
            break; 
        } 
    } 
} 


Please let us know, if you need further assistance. 

Regards, 
Manivel 


Loader.
Up arrow icon