Hello team,
I have two requirements,
1) Let say, I have TreeGrid A and TreeGrid B. I should be able to drag and drop items from TreeGrid A to TreeGrid B only. I want to restrict drag and drop action from TreeGrid B to TreeGrid A.
2) There should be a way to restrict drag and drop action within TreeGrid A and at the same time I should be able to drag and drop from
TreeGrid
A to
TreeGrid
B.
3) When I drag an item from TreeGrid A and drop at TreeGrid B, the item should not be removed from TreeGrid A i.e. I just want to drag a copy of an item from TreeGrid A and drop at TreeGrid B.
I am not sure how to enable the above mentioned requirements if they are already present. Please help.
Thank you,
Nikitha R
<ejs-treegrid #treegridA id="TreeGridA" [dataSource]='data1' height='360' childMapping='subtasks'
[treeColumnIndex]='1' [editSettings]='editOptions' [allowRowDragAndDrop]='true'
[selectionSettings]='selectOptions' (rowDrop)='droptoTreeGridB($event)'>
<e-columns>
<e-column field='taskID' headerText='Task ID' isPrimaryKey='true' width='70' textAlign='Right'>
</e-column>
</ejs-treegrid>
<ejs-treegrid #treegridB id='TreeGridB' height='315' [dataSource]='data2'
[treeColumnIndex]='1' childMapping='subtasks' [selectionSettings]='selectOptions'
[editSettings]='editOptions'>
<e-columns>
<e-column field='taskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90>
</e-column>
<e-column field='taskName' headerText='Task Name' textAlign='Left' width=180></e-column>
</e-columns>
</ejs-treegrid>
ngOnInit(): void {
this.data1 = sampleData1;
this.data2 = sampleData2;
this.selectOptions = { type: 'Multiple' };
this.editOptions = {
allowEditing: true,
allowAdding: true,
allowDeleting: true
};
}
droptoTreeGridB(args: any) {
args.cancel = true;
var ele = args.target.closest('.e-treegrid');
if (ele.id == 'TreeGridB') {
var treegridB = (document.getElementById('TreeGridB') as any)
.ej2_instances[0];
var treegridA = (document.getElementById('TreeGridA') as any)
.ej2_instances[0];
var rowIndex = !isNullOrUndefined(args.target.closest('.e-row'))
? args.target.closest('.e-row').rowIndex
: 0;
for (var i = 0; i < args.data.length; i++) {
var indx = rowIndex + i;
treegridB.addRecord(args.data[i], indx);
}
}
}
|
Hello Padmavathy Kamalanathan,
Thank you for explaining this in detail. I see that edit setting was needed to meet my requirement.
Thank you so much.
Nikitha R
I have an issue when I put these two TreeGrids into ejs-splitter control.
TreeGrid A in one pane and TreeGrid B in another pane.
When I drag a record, the clone record appears and this clone record goes behind the pane of TreeGrid B.
I tried to override style z-index: 10 in class e-cloneproperties to z-index: 20.
It did not work. This is the same sample code with splitter
<div class="control-section" >
<ejs-splitter id='outterSplitter' #splitterInstance class="splitter-expand" #horizontal height='100%'
width='100%' separatorSize=3 >
<e-panes>
<e-pane size='50%'>
<ng-template #content>
<div>
<ejs-treegrid #treegridA id="TreeGridA" [dataSource]='data1' height='360'
childMapping='subtasks' [treeColumnIndex]='1' [editSettings]='editOptions'
[allowRowDragAndDrop]='true' [selectionSettings]='selectOptions'
(rowDrop)='droptoTreeGridB($event)'>
<e-columns>
<e-column field='taskID' headerText='Task ID' isPrimaryKey='true' width='70'
textAlign='Right'>
</e-column>
<e-column field='taskName' headerText='Task Name' width='200'></e-column>
<e-column field='duration' headerText='Duration' width='80' textAlign='Right'>
</e-column>
<e-column field='progress' headerText='Progress' width='80' textAlign='Right'>
</e-column>
<e-column field='priority' headerText='Priority' width='90'></e-column>
</e-columns>
</ejs-treegrid>
</div>
</ng-template>
</e-pane>
<e-pane>
<ng-template #content>
<div>
<ejs-treegrid #treegridB id='TreeGridB' height='315' [dataSource]='data2'
[allowRowDragAndDrop]='false' [treeColumnIndex]='1' childMapping='subtasks'
[selectionSettings]='selectOptions' [editSettings]='editOptions'>
<e-columns>
<e-column field='taskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right'
width=90>
</e-column>
<e-column field='taskName' headerText='Task Name' textAlign='Left' width=180></e-column>
</e-columns>
</ejs-treegrid>
</div>
</ng-template>
</e-pane>
</e-panes>
</ejs-splitter>
</div>
Thank you,
Nikitha R
<style>
.e-splitter.e-splitter-horizontal .e-pane.e-pane-horizontal,
.e-splitter.e-splitter-vertical .e-pane.e-pane-horizontal {
overflow: unset;
}
</style> |