Hi
please check below code . I have added the checkbox on parent and child level . but when on clicking the checkbox the change handler is not getting triggered . please suggest .
Thanks for the reply . I have implemented the same and I can get the checkbox event now .
Next thing I want to remove the check box for children level . The checkbox should be displayed only on parent node not on childern nodes . please help me out on this .
Hi Dileep,
Query#:- I want to remove the check box for children level . The checkbox should be displayed only on parent node not on childern nodes.
We have checked your query and achieved your requirement using queryCellInfo event of the TreeGrid. In this event we have hide the checkbox of the children records by adding custom CSS based on condition.
Refer to the code below:-
|
App.Component.html:-
<ejs-treegrid [dataSource]="data" allowPaging="true" height="350" childMapping="subtasks" [treeColumnIndex]="1" [selectionSettings]="selectionsettings" (checkboxChange)="checkboxChange($event)" (rowSelecting)="rowSelecting($event)" (queryCellInfo)="queryCellInfo($event)" > <e-columns> <e-column field="taskID" headerText="Task ID" isPrimaryKey="true" width="70" textAlign="Right" ></e-column> . . . </e-columns> </ejs-treegrid>
App.Component.ts queryCellInfo(args) { if (args.column.field == 'approved' && !args.data.hasChildRecords) { args.cell.closest('.e-templatecell').classList.add('e-custom'); //remove the checkbox for Parentrow by adding Custom class } }
App.Component.css:- <style> .e-templatecell.e-custom .e-checkbox-wrapper { display: none; } </style>
|
Sample link: https://stackblitz.com/edit/angular-gm58iq-qf5kc2?file=app.component.ts
Screenshot:-
API link:- https://ej2.syncfusion.com/angular/documentation/api/treegrid/#querycellinfo
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
I have applied the but it is not working I think the html and data from my side is different .
I am using below grid :
I debugged the htm part of checkbox using the query cell info , but how to apply the style for children checkbox.
Hi Dileep,
Query#:- I debugged the htm part of checkbox using the query cell info , but how to apply the style for children checkbox.
From your provided details we suspect that you need to hide the checkbox(i.e.type checkbox) of the children records. To achieve this, we have apply the Customization to .e-checkbox-wrapper on queryCellInfo event.
Refer to the code below:-
|
App.Component.ts
queryCellInfo(args) { if (args.column.field == 'approved' && !args.data.hasChildRecords) { args.cell.querySelector('.e-checkbox-wrapper').classList.add('e-custom'); // use this solution if you are using type checkbox // args.cell.closest('.e-templatecell').classList.add('e-custom'); //remove the checkbox for Parentrow by adding Custom class //use this solution if you are using template cell } }
App.component.css
<style> .e-checkbox-wrapper.e-custom { display: none; }
</style> |
Modified Sample link:- https://stackblitz.com/edit/angular-gm58iq-8sdcmb?file=app.component.html
If the above solution doesn’t meet the above requirement, share us the following details
Regards,
Farveen sulthana T
Thanks for the support
This issue is resolved and it is working now . I am able to hide the checkbox for childers level
Hi Dileep,
Thanks for your update. Please get back to us if you need any further assistance. We are happy to assist you.
Regards,
Farveen sulthana T