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);
}
};
} |
App.component.ts
import { comboBox } from "@syncfusion/ej2-dropdowns";
public comboData = ['Kevzara', 'Dupixent-AD', 'Dupixent', 'Dupixent AD','Kevaza’];
function write(args) {
dObj = new ej.dropdowns.ComboBox({
dataSource: comboData,
allowFiltering: true, //enable filtering
value: args.rowData[args.column.field]
});
dObj.appendTo(this.elem1);
}
|