<ng-template #checkboxedit let-data>
<ejs-checkbox [checked]='data.Discontinued' [disabled]="disabled" (change)='change($event, data)'></ejs-checkbox>
</ng-template>
export class BatchEditComponent implements OnInit {
....
public disabled = true;
.....
public ngOnInit(): void {
this.data = categoryData;
...
this.toolbar = [{ id: 'EnableEdit', text: 'Edit'}, { id: 'CancelEdit', text: 'Cancel'}];
.....
}
toolbarClick(args){
if (args.item.id === 'EnableEdit') {
this.grid.editSettings ={ allowEditing: true, allowAdding: true, mode: 'Batch' };
this.disabled = false;
}
if (args.item.id === 'CancelEdit') {
this.grid.editSettings ={ allowEditing: false, allowAdding: false, mode: 'Batch' };
this.disabled = true;
}
}
.....
}
|
Hi Shamil,
Thanks for contacting Syncfusion support.
We have modified the sample to achieve your requirement in which custom edit and delete toolbar items are used to enable/disable edit in grid and also used disabled property of the checkbox to toggle its enable state.
<ng-template #checkboxedit let-data><ejs-checkbox [checked]='data.Discontinued' [disabled]="disabled" (change)='change($event, data)'></ejs-checkbox></ng-template>
export class BatchEditComponent implements OnInit {....public disabled = true;.....public ngOnInit(): void {this.data = categoryData;...this.toolbar = [{ id: 'EnableEdit', text: 'Edit'}, { id: 'CancelEdit', text: 'Cancel'}];.....}toolbarClick(args){if (args.item.id === 'EnableEdit') {this.grid.editSettings ={ allowEditing: true, allowAdding: true, mode: 'Batch' };this.disabled = false;}if (args.item.id === 'CancelEdit') {this.grid.editSettings ={ allowEditing: false, allowAdding: false, mode: 'Batch' };this.disabled = true;}}.....}
Regards,Madhu Sudhanan P
Hi Shamil,
Thanks for the update.
We have toggled the toolbar items as per your requirement using enableItems method of the toolbar module and also canceled batch changes on cancel click using batchCancel method. Please find the below modified sample.
API used
Regards,Madhu Sudhanan P