<ejs-treegrid #treegrid [dataSource]='data' childMapping='subtasks'
[treeColumnIndex]='1' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='taskID' headerText='Task ID' isPrimaryKey='true'
width='90' textAlign='Right'></e-column>
----------
<e-column field='approved' headerText='CheckBox'
width='90' textAlign='Center'>
<ng-template #template let-data>
<ejs-checkbox id='check{{data.taskID}}' #checkbox
(change)="changeHandler($event, data)"
[checked]=data.approved></ejs-checkbox>
</ng-template>
</e-column>
</e-columns>
</ejs-treegrid>
public changeHandler(args: ChangeEventArgs, data: any) : void {
console.log(data); // row's data
data.approved = args.checked; // setting the changed value to checkbox field
var index = data.index; // row's index
this.treegrid.updateRow(index, data);
// updating the changed value to dataSource
console.log(this.treegrid.dataSource);
}
|
Hi Puneet,Thanks for contacting Syncfusion Forums.QUERY: edit checkbox inside template in single clickWe have rendered checkbox in column template of Tree Grid and achieved the single click editing and also updated the data back to Tree Grid as described below,
- We have binded the change event to the checkbox in the column template.
- On checking/unchecking the checkbox, checkbox change event will be triggered. In that event, we have passed the row data along with the index of the corresponding row. Also the arguments of the change event will contain the changed value of checkbox.
- Using the "UpdateRow" method of Tree Grid , we have updated the value back to Tree Grid .
Please check the below code snippet,
<ejs-treegrid #treegrid [dataSource]='data' childMapping='subtasks'[treeColumnIndex]='1' [editSettings]='editSettings' [toolbar]='toolbar'><e-columns><e-column field='taskID' headerText='Task ID' isPrimaryKey='true'width='90' textAlign='Right'></e-column>----------<e-column field='approved' headerText='CheckBox'width='90' textAlign='Center'><ng-template #template let-data><ejs-checkbox id='check{{data.taskID}}' #checkbox(change)="changeHandler($event, data)"[checked]=data.approved></ejs-checkbox></ng-template></e-column></e-columns></ejs-treegrid>public changeHandler(args: ChangeEventArgs, data: any) : void {console.log(data); // row's datadata.approved = args.checked; // setting the changed value to checkbox fieldvar index = data.index; // row's indexthis.treegrid.updateRow(index, data);// updating the changed value to dataSourceconsole.log(this.treegrid.dataSource);}Please check the below sample,Please check the below help documentation,Kindly get back to us for further assistance.Regards,Padmavathy Kamalanathan