App.component.ts
import { Component, OnInit, ViewChild } from "@angular/core";
import { orderDataSource } from "./data";
import { DropDownList } from "@syncfusion/ej2-dropdowns";
import { Button } from "@syncfusion/ej2-buttons";
@Component({
selector: "app-root",
template: ` <ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='ShipCity' headerText='Ship City' width='150' [edit]='shipCityEditParams'></e-column>
</e-columns>
})
export class AppComponent {
@ViewChild("grid", { static: true }) gridObj: GridComponent;
public dropDataSource = [
{ text: "Köln", value: 1 },
…
];
public ngOnInit(): void {
this.data = orderDataSource;
this.editSettings = {allowEditing: true, allowAdding: true,allowDeleting: true, mode: "Batch"};
this.toolbar = ["Add", "Edit", "Delete", "Cancel", "Update"];
this.shipCityEditParams = {
create: () => {
this.elem1 = document.createElement('input');
return this.elem1;
},
read: () => {
return this.dropObj.text;
},
destroy: () => {
this.dropObj.destroy();
},
write: (args: { rowData: object, column: Column }) => {
this.dropObj = new DropDownList({
dataSource: this.dropDataSource,
text: args.rowData[args.column.field],
fields: { text: 'text', value: 'value' },
floatLabelType: 'Never'
});
this.dropObj.appendTo(this.elem1);
}
};
} |