Hi Willemin,
Thanks for contacting Syncfusion support.
You can achieve your requirement by using columnTemplate feature of EJ2 Grid. By using this feature we have rendered the checkbox in the column. When you change the state of check element, the change event will be triggered. In that event, we manually update the cell value using updateCell method. find the below code example and sample for your reference.
[app.component.html]
<ejs-grid #grid [dataSource]='dataSource' (cellEdit)="cellEdit($event)" height='400px'>
<e-columns>
----
<e-column field='masculin'>
<ng-template #template let-data>
<ejs-checkbox [checked]="data.masculin" (change)="checkBoxChange($event)">
</ejs-checkbox>
</ng-template>
</e-column>
</e-columns>
</ejs-grid>
[app.component.ts]
checkBoxChange(args: any){
// get the row details using the target element
var rowInfo: any = this.grid.getRowInfo(args.event.target.closest("td"))
// update the cell value
this.grid.updateCell(rowInfo.rowIndex, rowInfo["column"]["field"], args.checked); // updateCell (rowIndex, field, value)
}
cellEdit(args: any){
if(args.columnName == "masculin"){
// prevent the edit action on double click
args.cancel = true;
}
}
|
Query #2: When we try to copy and paste the boolean values displayed in the checkbox, we don't copy anything.
When you copy the values in the Grid, it only copy the innerText of the cell. It does not copy the value of the custom element rendered in the Grid column. Since this is the intended behavior of EJ2 Grid.
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S