|
[App.component.html]
<div class="control-section">
<button ejs-button (click)="buttonClick()" [isPrimary]="true">Update and get Data</button>
<ejs-grid #batchgrid id='Batchgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' isPrimaryKey='true' [validationRules]='orderidrules'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='120' [validationRules]='customeridrules'></e-column>
<e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' editType='numericedit' [validationRules]='freightrules'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='130' format='yMd' editType='datepickeredit' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit' [edit]='editparams'></e-column>
</e-columns>
</ejs-grid>
</div> |
|
[App.component.ts]
export class AppComponent {
@ViewChild('batchgrid',{static: true})
public grid: GridComponent;
public orderidrules: Object;
public ngOnInit(): void {
this.data = orderData;
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true,showConfirmDialog : false
, mode: 'Batch' };
this.toolbar = ['Add', 'Delete', 'Update', 'Cancel'];
this.orderidrules = { required: true, number: true };
this.customeridrules = { required: true };
this.freightrules = { required: true };
this.editparams = { params: { popupHeight: '300px' }};
this.pageSettings = {pageCount: 5};
}
buttonClick (args) {
// to perform the action of the update toolbar programmatically
this.grid.editModule.batchSave();
console.log(this.grid.getCurrentViewRecords());
}
} |