import { Component, OnInit } from '@angular/core';
import { data } from './data';
import { CommandModel, EditSettingsModel,iterateExtend } from '@syncfusion/ej2-angular-grids';
@Component({
selector: 'app-root',
template: `<ejs-grid [dataSource]='data' [editSettings]='editSettings' height='400px'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' isPrimaryKey='true' width=100></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' textAlign= 'Right'
editType= 'numericedit' width=120 format= 'C2'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' editType= 'dropdownedit' [edit]='ddParams' width=150></e-column>
<e-column headerText='Commands' width=120 [commands]='commands'></e-column>
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
public data: object[];
public editSettings: EditSettingsModel;
public commands: CommandModel[];
public ddParams: any;
ngOnInit(): void {
this.data = data;
// here we are iterating and extending the grid data to dropdown to avoid object reference
this.ddParams = { params: { dataSource: iterateExtend(data) } };
. . .
} |
[app.component.ts]
this.ddParams = { params: { dataSource: iterateExtend(data),change:this.dropdownChange } };
dropdownChange(args){
// write your c
}
|