When I drag a treegrid row, I would like to change the indicator in the RowDrag event to let the user know that they cannot drop into a row.
How can I access that property in the RowDrag event to modif
Hi Jagadesh,
I tried to implement the examples, but where I ran into an issue was on this line:
this.rowDragAndDropModule.addErrorElem();
This is how I coded it:
It says addErrorElem does not exist in rowDragAndDropModule
.addErrorElem();
|
[app.component.ts]
rowDrop(args: any) { var treeGridobj = document.getElementsByClassName('e-treegrid')[0].ej2_instances[0];
var data = treeGridobj.getCurrentViewRecords()[args.dropIndex];
if (data.hasChildRecords) { //apply your own customized condition
args.cancel = 'true'
alert("dropping disabled for parent row") //alert message while dropping on parent row
}
}
rowDrag (args: any) {
var treeGridobj = document.getElementsByClassName('e-treegrid')[0].ej2_instances[0];
var rowEle: Element = args.target ? args.target.closest('tr') : null;
var rowIdx: number = rowEle ? (rowEle as HTMLTableRowElement).rowIndex : -1;
var currentData = treeGridobj.getCurrentViewRecords()[rowIdx];
if (rowIdx !== -1) {
if (currentData.hasChildRecords)
treeGridobj.rowDragAndDropModule.addErrorElem(); //shows (no drop) icon for the parent records
}
}
|
|
[app.component.html]
<ejs-treegrid #treegrid [dataSource]='data' height='350' childMapping='subtasks' [treeColumnIndex]='1' [allowRowDragAndDrop]='true' [selectionSettings]='selectOptions' (rowDrop)='rowDrop($event)'
(rowDrag)='rowDrag($event)'>
<e-columns>
.......
</e-columns>
</ejs-treegrid>
|
Thank you. That worked!