- Home
- Forum
- Angular - EJ 2
- Feature requirement
Feature requirement
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
- We have rendered Tree Grid A with Row Drag and Drop feature enabled(setting allowRowDragAndDrop property to true) and Tree Grid B with Row Drag and Drop feature disabled.
- Row Drop event get triggered when we drop a record in Tree Grid. If we drag record from Tree Grid A and dropped it to Tree Grid B, RowDrop event of Tree Grid A will be triggered.
- In RowDrop event of Tree Grid A, we have set args.cancel to true and customized row drop .
- Setting args.cancel will prevent normal row drop functionality. This will prevent Row DD within Tree Grid A.
- In that RowDrop event, we have checked if the target is Tree Grid B. If yes, we have accessed the drop index of Tree Grid B. Then we have added the dragged record to Tree Grid B using addRecord method. Thus record get added to Tree Grid B.
- Since we do not use default RowDD feature (only added record with addRecord method ) , record dragged from Tree Grid A will not get removed
- Since we have not enabled Row Drag and Drop feature in Tree Grid B, Row DD will be prevented from Tree Grid B to Tree Grid A.
|
<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> |
- 6 Replies
- 3 Participants
- Marked answer
-
NI Nikitha
- Jul 19, 2021 11:37 AM UTC
- Jul 26, 2021 05:29 AM UTC