List of array of objects in Angular Grid component
The Syncfusion Angular Grid allows binding data sources containing arrays of objects, including support for complex field structures. This enables display and manipulation of nested data within the grid columns.
The following example demonstrates how to configure a complex field and bind a data source consisting of an array of objects.
import { complexData } from './datasource';
import { Component, OnInit } from '@angular/core';
import { GridModule } from '@syncfusion/ej2-angular-grids';
@Component({
imports: [ GridModule ],
standalone: true,
selector: 'app-root',
template: `<ejs-grid #grid [dataSource]='data' [height]='315'>
<e-columns>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=120></e-column>
<e-column field='Names.0.FirstName' headerText='First Name' width=120></e-column>
<e-column field='Names.0.LastName' headerText='Last Name' width=120></e-column>
<e-column field='Title' headerText='Title' width=150></e-column>
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
public data?: object[];
ngOnInit(): void {
this.data = complexData;
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));