Hello. I am using treegrid component and I'm trying to disable editing of given cells. I would like to check if row fulfills given condition and if it does - disable editing for some of its cells. I was trying to use queryCellInfo event, but it didn't find how to do it.
I tried this:
queryCellInfo(args: any) {
const columnName = (args.column as Column).field;
if (args.data.condition) {
if (columnName === 'columnToDisable') {
args.cell?.setAttribute('style', 'pointer-events: none;');
}
}
}
But it didn't work for me as I expected, because I could edit 'columnToDisable' cell, by clicking on any other cell and using tab to disabled cell.
|
columns: [
{ field: "taskID", headerText: "Task Id", width: "45" },
{ field: "taskName", headerText: "Task Name", allowEditing: false },
{ field: "startDate", headerText: "Start Date", format: dateFormat },
],
|
Hello. I am very sorry, but this is not exactly what I need. AllowEditing property disables editing of given column for every row. Unfortunately I need something more complex. I want to be able to disable editing of certain columns only for rows, which have childRecords.
Lets say we have 2 columns: "Name" and "Age". I want to be able to edit "Age" column for every row, but also I want to be able to edit "Name" column ONLY for rows, which don't have child records. I tried something llike this, but it doesn't work for me (treegrid.refreshColumns() cancels editing):
component.ts:
component.html:
Hi Marek ,
We have forwarded your query to the concerned team. Our team will provide an update on 30th March. We appreciate your patience until then.
Regards,
Premkumar S
Hi Marek Moryl,
Thanks for your patience.
Query: I want to be able to disable editing of certain columns only for rows, which have childRecords.
Based on your query, we understand you need to disable editing for some columns on parent rows with edit mode as Row. We achieved your query by using the actionComplete event of the treegrid.
Please refer to the below code snippet,
|
<ejs-treegrid #treegrid [dataSource]="data" height="400" childMapping="subtasks" [treeColumnIndex]="1" [editSettings]="editSettings" [toolbar]="toolbar" (actionComplete)="actionComplete($event)" >
actionComplete(args) { if ( args.requestType == 'beginEdit' && args.rowData.hasChildRecords == true //Check the selected row is parent or not ) { var Inx = this.treegrid.getColumnIndexByField('duration'); // get the index of disable column which you want.. here we disable the duration column
this.treegrid.grid.editModule.formObj.element[Inx].disabled = true; // disable the particular cell value while editing }
|
In the above code snippet, we get the value from the grid's edit module.
Please refer to the below sample,
https://stackblitz.com/edit/angular-bpwjqh-en45do?file=app.component.ts
Please refer to the below API documentation,
https://ej2.syncfusion.com/documentation/api/treegrid/#actioncomplete
Kindly get back to us for further assistance.
Regards,
Pon selva
Hi Marek Moryl,
Thanks for the update.
We are glad to hear your query has been solved by our solution.
Kindly get back to us for further assistance. We are happy to assist you.
Regards,
Pon selva