@Component({
selector: 'app-root',
template: `<ejs-grid #grid [dataSource]="data" [toolbar]="toolbar" (actionBegin)="actionBegin($event)">
<e-columns>
<e-column field="number1" isPrimaryKey='true' headerText="Nummer"></e-column>
<e-column field="number2" headerText="Nummer">
<ng-template #editTemplate let-data>
<ejs-textbox [(ngModel)]="orderData.number2"></ejs-textbox>
</ng-template>
</e-column>
<e-column field="name" headerText="Naam">
<ng-template #editTemplate let-data>
<ejs-textbox [(ngModel)]="orderData.name"></ejs-textbox>
</ng-template>
</e-column>
</e-columns>
</ejs-grid>`
})
export class AppComponent {
. . .
actionBegin(args: SaveEventArgs) {
if (args.requestType === 'beginEdit' || args.requestType === 'add') {
this.orderData = Object.assign({}, args.rowData);
}
if (args.requestType === 'save') {
// cast string to integer value.
args.data['number2'] = this.orderData['number2'];
args.data['name'] = this.orderData['name'];
}
}
}
|
That is an awful workaround. More evidence of how poorly these controls are built and maintained
<ejs-grid #grid [dataSource]="data" [toolbar]="toolbar">
<e-columns>
<e-column field="number1" isPrimaryKey='true' headerText="Nummer"></e-column>
<e-column field="number2" headerText="Nummer"> //set the column field name to the control name to save the value
<ng-template #editTemplate let-data>
<ejs-textbox name="number2" [(ngModel)]="data.number2"></ejs-textbox>
</ng-template>
</e-column>
<e-column field="name" headerText="Name">
<ng-template #editTemplate let-data>
<ejs-textbox name="name" [(ngModel)]="data.name"></ejs-textbox>
</ng-template>
</e-column>
</e-columns>
</ejs-grid> |
Hello Rajapandi Ravi,
your solution using the name attribute of the column in the editor component only works for Syncfusion components, right? At least, our own test using a custom editor component didn't work.
Any suggestions??? Besides using actionBegin event...
Kind regards,
Marc