@syncfusion/ej2-treegrid 27.2.3 → 28.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +2 -2
  2. package/dist/ej2-treegrid.min.js +3 -3
  3. package/dist/ej2-treegrid.umd.min.js +3 -3
  4. package/dist/ej2-treegrid.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-treegrid.es2015.js +566 -251
  6. package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
  7. package/dist/es6/ej2-treegrid.es5.js +570 -251
  8. package/dist/es6/ej2-treegrid.es5.js.map +1 -1
  9. package/dist/global/ej2-treegrid.min.js +3 -3
  10. package/dist/global/ej2-treegrid.min.js.map +1 -1
  11. package/dist/global/index.d.ts +2 -2
  12. package/package.json +10 -10
  13. package/src/treegrid/actions/batch-edit.js +58 -56
  14. package/src/treegrid/actions/context-menu.js +3 -1
  15. package/src/treegrid/actions/reorder.d.ts +1 -1
  16. package/src/treegrid/actions/reorder.js +5 -17
  17. package/src/treegrid/actions/rowdragdrop.d.ts +286 -14
  18. package/src/treegrid/actions/rowdragdrop.js +447 -161
  19. package/src/treegrid/actions/virtual-scroll.js +5 -0
  20. package/src/treegrid/base/data.js +22 -5
  21. package/src/treegrid/base/treegrid.d.ts +1 -0
  22. package/src/treegrid/base/treegrid.js +27 -10
  23. package/src/treegrid/renderer/virtual-tree-content-render.js +4 -2
  24. package/styles/bds-lite.css +703 -0
  25. package/styles/bds-lite.scss +18 -0
  26. package/styles/bds.css +723 -0
  27. package/styles/bds.scss +19 -0
  28. package/styles/bootstrap-dark-lite.css +20 -0
  29. package/styles/bootstrap-dark.css +26 -6
  30. package/styles/bootstrap-lite.css +20 -0
  31. package/styles/bootstrap.css +26 -6
  32. package/styles/bootstrap4-lite.css +20 -0
  33. package/styles/bootstrap4.css +26 -6
  34. package/styles/bootstrap5-dark-lite.css +20 -0
  35. package/styles/bootstrap5-dark.css +26 -6
  36. package/styles/bootstrap5-lite.css +20 -0
  37. package/styles/bootstrap5.3-lite.css +20 -0
  38. package/styles/bootstrap5.3.css +26 -6
  39. package/styles/bootstrap5.css +26 -6
  40. package/styles/fabric-dark-lite.css +20 -0
  41. package/styles/fabric-dark.css +26 -6
  42. package/styles/fabric-lite.css +20 -0
  43. package/styles/fabric.css +26 -6
  44. package/styles/fluent-dark-lite.css +20 -0
  45. package/styles/fluent-dark.css +27 -7
  46. package/styles/fluent-lite.css +20 -0
  47. package/styles/fluent.css +27 -7
  48. package/styles/fluent2-lite.css +20 -0
  49. package/styles/fluent2.css +28 -8
  50. package/styles/highcontrast-light-lite.css +20 -0
  51. package/styles/highcontrast-light.css +26 -6
  52. package/styles/highcontrast-lite.css +21 -1
  53. package/styles/highcontrast.css +28 -8
  54. package/styles/material-dark-lite.css +20 -0
  55. package/styles/material-dark.css +26 -6
  56. package/styles/material-lite.css +20 -0
  57. package/styles/material.css +26 -6
  58. package/styles/material3-dark-lite.css +20 -0
  59. package/styles/material3-dark.css +26 -6
  60. package/styles/material3-lite.css +20 -0
  61. package/styles/material3.css +26 -6
  62. package/styles/tailwind-dark-lite.css +20 -0
  63. package/styles/tailwind-dark.css +26 -6
  64. package/styles/tailwind-lite.css +20 -0
  65. package/styles/tailwind.css +26 -6
  66. package/styles/tailwind3-lite.css +511 -0
  67. package/styles/tailwind3-lite.scss +18 -0
  68. package/styles/tailwind3.css +531 -0
  69. package/styles/tailwind3.scss +19 -0
  70. package/styles/treegrid/_bigger.scss +45 -41
  71. package/styles/treegrid/_layout.scss +23 -2
  72. package/styles/treegrid/_tailwind3-definition.scss +24 -0
  73. package/styles/treegrid/bds.css +723 -0
  74. package/styles/treegrid/bds.scss +19 -0
  75. package/styles/treegrid/bootstrap-dark.css +26 -6
  76. package/styles/treegrid/bootstrap.css +26 -6
  77. package/styles/treegrid/bootstrap4.css +26 -6
  78. package/styles/treegrid/bootstrap5-dark.css +26 -6
  79. package/styles/treegrid/bootstrap5.3.css +26 -6
  80. package/styles/treegrid/bootstrap5.css +26 -6
  81. package/styles/treegrid/fabric-dark.css +26 -6
  82. package/styles/treegrid/fabric.css +26 -6
  83. package/styles/treegrid/fluent-dark.css +27 -7
  84. package/styles/treegrid/fluent.css +27 -7
  85. package/styles/treegrid/fluent2.css +28 -8
  86. package/styles/treegrid/highcontrast-light.css +26 -6
  87. package/styles/treegrid/highcontrast.css +28 -8
  88. package/styles/treegrid/icons/_tailwind3.scss +37 -0
  89. package/styles/treegrid/material-dark.css +26 -6
  90. package/styles/treegrid/material.css +26 -6
  91. package/styles/treegrid/material3-dark.css +26 -6
  92. package/styles/treegrid/material3.css +26 -6
  93. package/styles/treegrid/tailwind-dark.css +26 -6
  94. package/styles/treegrid/tailwind.css +26 -6
  95. package/styles/treegrid/tailwind3.css +531 -0
  96. package/styles/treegrid/tailwind3.scss +19 -0
@@ -1,6 +1,6 @@
1
1
  import { Grid, RowDD as GridDragDrop, parentsUntil } from '@syncfusion/ej2-grids';
2
2
  import { getObject, Scroll } from '@syncfusion/ej2-grids';
3
- import { closest, isNullOrUndefined, classList, setValue, extend, getValue, removeClass, addClass, setStyleAttribute } from '@syncfusion/ej2-base';
3
+ import { closest, isNullOrUndefined, setValue, extend, getValue, removeClass, addClass, setStyleAttribute } from '@syncfusion/ej2-base';
4
4
  import { DataManager } from '@syncfusion/ej2-data';
5
5
  import * as events from '../base/constant';
6
6
  import { editAction } from './crud-actions';
@@ -17,24 +17,44 @@ var RowDD = /** @class */ (function () {
17
17
  * @param {TreeGrid} parent - Tree Grid instance
18
18
  */
19
19
  function RowDD(parent) {
20
- /** @hidden */
20
+ /** @hidden
21
+ * Indicates whether a row can be dropped into the current target position during a drag-and-drop operation.
22
+ */
21
23
  this.canDrop = true;
22
- /** @hidden */
24
+ /** @hidden
25
+ * Indicates whether the current drag operation includes child records of the dragged item.
26
+ */
23
27
  this.isDraggedWithChild = false;
24
- /** @hidden */
28
+ /** @hidden
29
+ * Indicates whether multiple TreeGrid instances are being managed or displayed.
30
+ */
25
31
  this.modifiedRecords = 'modifiedRecords';
26
- /** @hidden */
32
+ /** @hidden
33
+ * Represents the currently selected item in the TreeGrid.
34
+ */
27
35
  this.selectedRecords = 'selectedRecords';
28
- /** @hidden */
36
+ /** @hidden
37
+ * Holds an array of currently selected records in the TreeGrid.
38
+ */
29
39
  this.selectedRows = 'selectedRows';
30
- /** @hidden */
40
+ /** @hidden
41
+ * Indicates whether there is a droppable item in the TreeGrid.
42
+ */
31
43
  this.hasDropItem = true;
32
- /** @hidden */
44
+ /** @hidden
45
+ * Indicates whether the item is being added to the bottom of the TreeGrid.
46
+ */
33
47
  this.isaddtoBottom = false;
34
48
  Grid.Inject(GridDragDrop);
35
49
  this.parent = parent;
36
50
  this.addEventListener();
37
51
  }
52
+ /**
53
+ * Retrieves child records for a specified parent ID in the TreeGrid.
54
+ *
55
+ * @param {string} id - The unique ID of the parent record for which to retrieve child records.
56
+ * @returns {ITreeData[]} An array of child records corresponding to the specified parent ID.
57
+ */
38
58
  RowDD.prototype.getChildrecordsByParentID = function (id) {
39
59
  var treeGridDataSource;
40
60
  if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
@@ -68,6 +88,9 @@ var RowDD = /** @class */ (function () {
68
88
  */
69
89
  RowDD.prototype.reorderRows = function (fromIndexes, toIndex, position) {
70
90
  var tObj = this.parent;
91
+ if (fromIndexes[0] === toIndex || ['above', 'below', 'child'].indexOf(position) === -1) {
92
+ return;
93
+ }
71
94
  var action = 'action';
72
95
  var dropPosition = 'dropPosition';
73
96
  var updateRowAndCellElements = 'updateRowAndCellElements';
@@ -106,13 +129,9 @@ var RowDD = /** @class */ (function () {
106
129
  }
107
130
  this.parent.grid.refresh();
108
131
  if (this.parent.enableImmutableMode && this.dropPosition === 'middleSegment') {
109
- var index = void 0;
110
- if (this.parent.allowRowDragAndDrop) {
111
- index = this.parent.treeColumnIndex + 1;
112
- }
113
- else if (this.parent["" + action] === 'indenting') {
114
- index = this.parent.treeColumnIndex;
115
- }
132
+ var index = this.parent.allowRowDragAndDrop
133
+ ? this.parent.treeColumnIndex + 1
134
+ : (this.parent["" + action] === 'indenting' ? this.parent.treeColumnIndex : undefined);
116
135
  var row = this.parent.getRows()[fromIndexes[0]];
117
136
  var dropData = args.data[0];
118
137
  var totalRecord = [];
@@ -127,13 +146,9 @@ var RowDD = /** @class */ (function () {
127
146
  this.parent["" + updateRowAndCellElements](totalRecord, rows, index);
128
147
  }
129
148
  if (this.parent.enableImmutableMode && this.parent["" + action] === 'outdenting') {
130
- var index = void 0;
131
- if (this.parent.allowRowDragAndDrop) {
132
- index = this.parent.treeColumnIndex + 1;
133
- }
134
- else if (this.parent["" + action] === 'outdenting') {
135
- index = this.parent.treeColumnIndex;
136
- }
149
+ var index = this.parent.allowRowDragAndDrop
150
+ ? this.parent.treeColumnIndex + 1
151
+ : (this.parent["" + action] === 'outdenting' ? this.parent.treeColumnIndex : undefined);
137
152
  var record = args.data[0];
138
153
  var row = this.parent.getRows()[fromIndexes[0]];
139
154
  var totalRecord = [];
@@ -143,10 +158,14 @@ var RowDD = /** @class */ (function () {
143
158
  this.parent["" + updateRowAndCellElements](totalRecord, rows, index);
144
159
  }
145
160
  }
146
- else {
147
- return;
148
- }
149
161
  };
162
+ /**
163
+ * Performs indent or outdent actions on selected records in the TreeGrid.
164
+ *
165
+ * @param {ITreeData} [record] - The record to be indented or outdented. If undefined, the method operates on the currently selected record.
166
+ * @param {string} [request] - The action to perform, either 'indent' or 'outdent'.
167
+ * @returns {void}
168
+ */
150
169
  RowDD.prototype.indentOutdentAction = function (record, request) {
151
170
  var tObj = this.parent;
152
171
  var action = 'action';
@@ -221,6 +240,13 @@ var RowDD = /** @class */ (function () {
221
240
  }
222
241
  }
223
242
  };
243
+ /**
244
+ * Triggers a specified event for the TreeGrid, notifying subscribers about the event occurrence.
245
+ *
246
+ * @param {string} action - The action to be triggered, either 'indenting' or 'outdenting'.
247
+ * @param {number} dropIndex - The index at which the row should be dropped.
248
+ * @returns {void}
249
+ */
224
250
  RowDD.prototype.eventTrigger = function (action, dropIndex) {
225
251
  var _this = this;
226
252
  var actionArgs = {
@@ -250,6 +276,12 @@ var RowDD = /** @class */ (function () {
250
276
  }
251
277
  });
252
278
  };
279
+ /**
280
+ * Reorders the flat data array of the TreeGrid and updates the index of each record.
281
+ *
282
+ * @param {ITreeData[]} currentData - The array of tree data records to reorder.
283
+ * @returns {ITreeData[]} The updated array of tree data records with indices set.
284
+ */
253
285
  RowDD.prototype.orderToIndex = function (currentData) {
254
286
  for (var i = 0; i < currentData.length; i++) {
255
287
  currentData[parseInt(i.toString(), 10)].index = i;
@@ -260,6 +292,15 @@ var RowDD = /** @class */ (function () {
260
292
  }
261
293
  return currentData;
262
294
  };
295
+ /**
296
+ * Handles the addition of new rows to the TreeGrid.
297
+ *
298
+ * @param {Object} e - The event object containing information about the rows being added.
299
+ * @param {number} e.toIndex - The index at which the new rows should be added in the TreeGrid.
300
+ * @param {Object[]} e.records - An array of the records to be added to the TreeGrid.
301
+ *
302
+ * @returns {void} This function does not return any value.
303
+ */
263
304
  RowDD.prototype.rowsAdded = function (e) {
264
305
  var draggedRecord;
265
306
  var dragRecords = e.records;
@@ -364,6 +405,15 @@ var RowDD = /** @class */ (function () {
364
405
  this.dropRows(args);
365
406
  }
366
407
  };
408
+ /**
409
+ * Handles the removal of specified rows from the TreeGrid.
410
+ *
411
+ * @param {Object} e - The event object containing information about the removed rows.
412
+ * @param {number[]} e.indexes - An array of indexes of the rows that were removed.
413
+ * @param {Object[]} e.records - An array of the records corresponding to the removed rows.
414
+ *
415
+ * @returns {void} This function does not return any value.
416
+ */
367
417
  RowDD.prototype.rowsRemoved = function (e) {
368
418
  for (var i = 0; i < e.records.length; i++) {
369
419
  this.draggedRecord = e.records[parseInt(i.toString(), 10)];
@@ -375,35 +425,36 @@ var RowDD = /** @class */ (function () {
375
425
  }
376
426
  }
377
427
  };
428
+ /**
429
+ * Refreshes the data source of the TreeGrid.
430
+ *
431
+ * @returns {void} This function does not return any value.
432
+ */
378
433
  RowDD.prototype.refreshGridDataSource = function () {
379
434
  var draggedRecord = this.draggedRecord;
380
435
  var droppedRecord = this.droppedRecord;
381
436
  var proxy = this.parent;
382
- var tempDataSource;
383
- var idx;
437
+ var temporaryDataSource;
438
+ var indexOfDroppedRecord;
384
439
  if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
385
- tempDataSource = proxy.dataSource.dataSource.json;
440
+ temporaryDataSource = proxy.dataSource.dataSource.json;
386
441
  }
387
442
  else {
388
- tempDataSource = proxy.dataSource;
443
+ temporaryDataSource = proxy.dataSource;
389
444
  }
390
- if (tempDataSource && (!isNullOrUndefined(droppedRecord) && !droppedRecord.parentItem)
445
+ if (temporaryDataSource && (!isNullOrUndefined(droppedRecord) && !droppedRecord.parentItem)
391
446
  && !isNullOrUndefined(droppedRecord.taskData)) {
392
- var keys = Object.keys(tempDataSource);
447
+ var keys = Object.keys(temporaryDataSource);
393
448
  for (var i = 0; i < keys.length; i++) {
394
- if (tempDataSource[parseInt(i.toString(), 10)][this.parent.childMapping] ===
449
+ if (temporaryDataSource[parseInt(i.toString(), 10)][this.parent.childMapping] ===
395
450
  droppedRecord.taskData[this.parent.childMapping]) {
396
- idx = i;
397
- }
398
- }
399
- if (this.dropPosition === 'topSegment') {
400
- if (!this.parent.idMapping) {
401
- tempDataSource.splice(idx, 0, draggedRecord.taskData);
451
+ indexOfDroppedRecord = i;
402
452
  }
403
453
  }
404
- else if (this.dropPosition === 'bottomSegment') {
405
- if (!this.parent.idMapping) {
406
- tempDataSource.splice(idx + 1, 0, draggedRecord.taskData);
454
+ if (!this.parent.idMapping) {
455
+ var positionAdjustment = this.dropPosition === 'topSegment' ? 0 : 1;
456
+ if (this.dropPosition === 'topSegment' || this.dropPosition === 'bottomSegment') {
457
+ temporaryDataSource.splice(indexOfDroppedRecord + positionAdjustment, 0, draggedRecord.taskData);
407
458
  }
408
459
  }
409
460
  }
@@ -434,6 +485,12 @@ var RowDD = /** @class */ (function () {
434
485
  }
435
486
  }
436
487
  };
488
+ /**
489
+ * Removes the border from the first row of the TreeGrid.
490
+ *
491
+ * @param {HTMLTableRowElement} element - The table row element from which to remove the border.
492
+ * @returns {void} This function does not return any value.
493
+ */
437
494
  RowDD.prototype.removeFirstrowBorder = function (element) {
438
495
  var canremove = this.dropPosition === 'bottomSegment';
439
496
  if (this.parent.element.getElementsByClassName('e-firstrow-border').length > 0 && element &&
@@ -441,25 +498,40 @@ var RowDD = /** @class */ (function () {
441
498
  this.parent.element.getElementsByClassName('e-firstrow-border')[0].remove();
442
499
  }
443
500
  };
501
+ /**
502
+ * Removes the border from the last row of the TreeGrid.
503
+ *
504
+ * @param {HTMLTableRowElement} element - The row element from which to remove the last row border.
505
+ * @returns {void}
506
+ */
444
507
  RowDD.prototype.removeLastrowBorder = function (element) {
445
- var isEmptyRow = element && (element.classList.contains('e-emptyrow') || element.classList.contains('e-columnheader')
446
- || element.classList.contains('e-detailrow'));
447
- var islastRowIndex;
448
- if (this.parent.enableVirtualization) {
449
- islastRowIndex = element && !isEmptyRow &&
450
- this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1].getAttribute('data-uid') !==
451
- element.getAttribute('data-uid');
508
+ if (!element) {
509
+ return;
452
510
  }
453
- else {
454
- islastRowIndex = element && !isEmptyRow &&
455
- this.parent.getRowByIndex(this.parent.getCurrentViewRecords().length - 1).getAttribute('data-uid') !==
456
- element.getAttribute('data-uid');
511
+ var isEmptyRow = element.classList.contains('e-emptyrow') ||
512
+ element.classList.contains('e-columnheader') ||
513
+ element.classList.contains('e-detailrow');
514
+ if (isEmptyRow) {
515
+ return;
457
516
  }
458
- var canremove = islastRowIndex || this.dropPosition === 'topSegment';
459
- if (this.parent.element.getElementsByClassName('e-lastrow-border').length > 0 && element && (islastRowIndex || canremove)) {
460
- this.parent.element.getElementsByClassName('e-lastrow-border')[0].remove();
517
+ var lastRow = this.parent.enableVirtualization ?
518
+ this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1] :
519
+ this.parent.getRowByIndex(this.parent.getCurrentViewRecords().length - 1);
520
+ var isNotLastRow = lastRow.getAttribute('data-uid') !== element.getAttribute('data-uid');
521
+ var canRemove = isNotLastRow || this.dropPosition === 'topSegment';
522
+ var lastRowBorderElement = this.parent.element.getElementsByClassName('e-lastrow-border')[0];
523
+ if (lastRowBorderElement && canRemove) {
524
+ lastRowBorderElement.remove();
461
525
  }
462
526
  };
527
+ /**
528
+ * Updates the icons associated with the specified rows in the TreeGrid.
529
+ *
530
+ * @param {Element[]} row - The array of row elements to update the icons for.
531
+ * @param {number} index - The index of the row being updated.
532
+ * @param {RowDragEventArgs} args - The event arguments associated with the row drag operation.
533
+ * @returns {string} The drop position ('topSegment', 'middleSegment', 'bottomSegment', or 'Invalid').
534
+ */
463
535
  RowDD.prototype.updateIcon = function (row, index, args) {
464
536
  var rowEle = args.target ? closest(args.target, 'tr') : null;
465
537
  this.dropPosition = undefined;
@@ -471,6 +543,10 @@ var RowDD = /** @class */ (function () {
471
543
  || !parentsUntil(args.target, 'e-gridcontent')) {
472
544
  this.dropPosition = 'Invalid';
473
545
  this.addErrorElem();
546
+ if (isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
547
+ this.removetopOrBottomBorder();
548
+ this.removeChildBorder();
549
+ }
474
550
  }
475
551
  }
476
552
  // To get the corresponding drop position related to mouse position
@@ -545,6 +621,11 @@ var RowDD = /** @class */ (function () {
545
621
  }
546
622
  return this.dropPosition;
547
623
  };
624
+ /**
625
+ * Removes the visual border from all child rows within the TreeGrid.
626
+ *
627
+ * @returns {void} No return value.
628
+ */
548
629
  RowDD.prototype.removeChildBorder = function () {
549
630
  var borderElem = [];
550
631
  borderElem = [].slice.call(this.parent.element.querySelectorAll('.e-childborder'));
@@ -552,6 +633,12 @@ var RowDD = /** @class */ (function () {
552
633
  this.addRemoveClasses(borderElem, false, 'e-childborder');
553
634
  }
554
635
  };
636
+ /**
637
+ * Adds a visual border to the first row of the TreeGrid.
638
+ *
639
+ * @param {HTMLTableRowElement} targetRow - The target row element to which the border will be added, if it is the first row.
640
+ * @returns {void} No return value.
641
+ */
555
642
  RowDD.prototype.addFirstrowBorder = function (targetRow) {
556
643
  var node = this.parent.element;
557
644
  var tObj = this.parent;
@@ -574,9 +661,21 @@ var RowDD = /** @class */ (function () {
574
661
  }
575
662
  }
576
663
  };
664
+ /**
665
+ * Adds a visual border to the last row of the TreeGrid.
666
+ *
667
+ * @param {HTMLTableRowElement} trElement - The table row element to which the border will be added, if it is the last row.
668
+ * @returns {void} No return value.
669
+ */
577
670
  RowDD.prototype.addLastRowborder = function (trElement) {
671
+ if (!trElement) {
672
+ return;
673
+ }
578
674
  var isEmptyRow = trElement && (trElement.classList.contains('e-emptyrow') ||
579
675
  trElement.classList.contains('e-columnheader') || trElement.classList.contains('e-detailrow'));
676
+ if (isEmptyRow) {
677
+ return;
678
+ }
580
679
  if (trElement && !isEmptyRow && this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1].getAttribute('data-uid') ===
581
680
  trElement.getAttribute('data-uid')) {
582
681
  var bottomborder = this.parent.createElement('div', { className: 'e-lastrow-border' });
@@ -589,40 +688,55 @@ var RowDD = /** @class */ (function () {
589
688
  }
590
689
  }
591
690
  };
691
+ /**
692
+ * Retrieves the total scroll width of the TreeGrid content area.
693
+ *
694
+ * @returns {number} The width of the scrollbar if content overflows, otherwise 0.
695
+ */
592
696
  RowDD.prototype.getScrollWidth = function () {
593
697
  var scrollElem = this.parent.getContent().firstElementChild;
594
698
  return scrollElem.scrollWidth > scrollElem.offsetWidth ? Scroll.getScrollBarWidth() : 0;
595
699
  };
700
+ /**
701
+ * Adds an error element to the dragged row element during a row drag-and-drop operation.
702
+ *
703
+ * @returns {void} No return value.
704
+ */
596
705
  RowDD.prototype.addErrorElem = function () {
597
706
  var dragelem = document.getElementsByClassName('e-cloneproperties')[0];
598
- var errorelem = dragelem.querySelectorAll('.e-errorelem').length;
707
+ var errorelemCount = dragelem.querySelectorAll('.e-errorelem').length;
599
708
  var sanitize = 'sanitize';
600
- if (!errorelem && !this.parent.rowDropSettings.targetID) {
601
- var ele = document.createElement('div');
602
- classList(ele, ['e-errorcontainer'], []);
603
- classList(ele, ['e-icons', 'e-errorelem'], []);
709
+ if (!errorelemCount && !this.parent.rowDropSettings.targetID) {
710
+ var errorContainer = document.createElement('div');
711
+ errorContainer.classList.add('e-errorcontainer', 'e-icons', 'e-errorelem');
712
+ var rowCell = dragelem.querySelector('.e-rowcell');
604
713
  var errorVal = dragelem.querySelector('.errorValue');
605
- var content = dragelem.querySelector('.e-rowcell').innerHTML;
714
+ var content = rowCell.innerHTML;
606
715
  if (errorVal) {
607
716
  content = this.parent["" + sanitize](errorVal.innerHTML);
608
717
  errorVal.parentNode.removeChild(errorVal);
609
718
  }
610
- dragelem.querySelector('.e-rowcell').innerHTML = '';
719
+ rowCell.innerHTML = '';
611
720
  var spanContent = document.createElement('span');
612
721
  spanContent.className = 'errorValue';
613
722
  spanContent.style.paddingLeft = '16px';
614
723
  spanContent.innerHTML = this.parent["" + sanitize](content);
615
- dragelem.querySelector('.e-rowcell').appendChild(ele);
616
- dragelem.querySelector('.e-rowcell').appendChild(spanContent);
724
+ rowCell.appendChild(errorContainer);
725
+ rowCell.appendChild(spanContent);
617
726
  var dropItemSpan = document.querySelector('.e-dropitemscount');
618
727
  if (this.hasDropItem && dropItemSpan) {
619
- var dropItemLeft = parseInt(dropItemSpan.style.left, 10) + ele.offsetWidth + 16;
728
+ var dropItemLeft = parseInt(dropItemSpan.style.left, 10) + errorContainer.offsetWidth + 16;
620
729
  var spanLeft = !this.parent.enableRtl ? dropItemLeft : 0;
621
730
  dropItemSpan.style.left = spanLeft + "px";
622
731
  this.hasDropItem = false;
623
732
  }
624
733
  }
625
734
  };
735
+ /**
736
+ * Removes the error element from the DOM and adjusts the position of the drop item count if necessary.
737
+ *
738
+ * @returns {void} No return value.
739
+ */
626
740
  RowDD.prototype.removeErrorElem = function () {
627
741
  var errorelem = document.querySelector('.e-errorelem');
628
742
  var errorValue = document.querySelector('.errorValue');
@@ -643,6 +757,12 @@ var RowDD = /** @class */ (function () {
643
757
  }
644
758
  this.hasDropItem = true;
645
759
  };
760
+ /**
761
+ * Applies drop border styles to row elements based on the current drop position ('topSegment' or 'bottomSegment').
762
+ *
763
+ * @param {Element} target - The target element where the drop action is taking place.
764
+ * @returns {void} No return value.
765
+ */
646
766
  RowDD.prototype.topOrBottomBorder = function (target) {
647
767
  var rowElement = [];
648
768
  var element = closest(target, 'tr');
@@ -659,6 +779,11 @@ var RowDD = /** @class */ (function () {
659
779
  }
660
780
  }
661
781
  };
782
+ /**
783
+ * Removes the drop border classes ('e-dropbottom' and 'e-droptop') from the parent element if present.
784
+ *
785
+ * @returns {void} No return value.
786
+ */
662
787
  RowDD.prototype.removetopOrBottomBorder = function () {
663
788
  var border = [];
664
789
  border = [].slice.call(this.parent.element.querySelectorAll('.e-dropbottom, .e-droptop'));
@@ -667,6 +792,14 @@ var RowDD = /** @class */ (function () {
667
792
  this.addRemoveClasses(border, false, 'e-droptop');
668
793
  }
669
794
  };
795
+ /**
796
+ * Adds or removes a specified class from a list of HTML elements.
797
+ *
798
+ * @param {Element[]} cells - The list of HTML elements to which the class will be added or removed.
799
+ * @param {boolean} add - A flag indicating whether to add (`true`) or remove (`false`) the class.
800
+ * @param {string} className - The class name to be added or removed from each element in `cells`.
801
+ * @returns {void} No return value.
802
+ */
670
803
  RowDD.prototype.addRemoveClasses = function (cells, add, className) {
671
804
  for (var i = 0, len = cells.length; i < len; i++) {
672
805
  if (add) {
@@ -677,6 +810,12 @@ var RowDD = /** @class */ (function () {
677
810
  }
678
811
  }
679
812
  };
813
+ /**
814
+ * Calculates the offset position of the specified HTML element relative to the document.
815
+ *
816
+ * @param {Element} element - The HTML element for which the offset position is calculated.
817
+ * @returns {PositionOffSet} The offset position containing `top` and `left` values.
818
+ */
680
819
  RowDD.prototype.getOffset = function (element) {
681
820
  var box = element.getBoundingClientRect();
682
821
  var body = document.body;
@@ -689,35 +828,38 @@ var RowDD = /** @class */ (function () {
689
828
  var left = box.left + scrollLeft - clientLeft;
690
829
  return { top: Math.round(top), left: Math.round(left) };
691
830
  };
831
+ /**
832
+ * Handles the dragging of rows in the TreeGrid.
833
+ *
834
+ * @param {RowDragEventArgs} args - The event arguments for the row drag action.
835
+ * @returns {void} This function does not return a value.
836
+ */
692
837
  RowDD.prototype.Rowdraging = function (args) {
693
838
  var tObj = this.parent;
694
839
  var cloneElement = this.parent.element.querySelector('.e-cloneproperties');
840
+ if (!cloneElement) {
841
+ return;
842
+ }
695
843
  cloneElement.style.cursor = '';
696
844
  var rowEle = args.target ? closest(args.target, 'tr') : null;
697
845
  var rowIdx = rowEle ? rowEle.rowIndex : -1;
698
- var dragRecords = [];
699
- var droppedRecord = tObj.getCurrentViewRecords()[parseInt(rowIdx.toString(), 10)];
700
- this.removeErrorElem();
701
- this.canDrop = true;
702
- if (!args.data[0]) {
703
- dragRecords.push(args.data);
704
- }
705
- else {
706
- dragRecords = args.data;
707
- }
708
- if (rowIdx !== -1) {
709
- this.ensuredropPosition(dragRecords, droppedRecord);
710
- }
711
- else {
846
+ if (rowIdx === -1) {
712
847
  this.canDrop = false;
713
848
  this.addErrorElem();
849
+ if (isNullOrUndefined(tObj.rowDropSettings.targetID)) {
850
+ this.removetopOrBottomBorder();
851
+ this.removeChildBorder();
852
+ }
853
+ return;
714
854
  }
855
+ var dragRecords = Array.isArray(args.data) ? args.data : [args.data];
856
+ var droppedRecord = tObj.getCurrentViewRecords()[parseInt(rowIdx.toString(), 10)];
857
+ this.removeErrorElem();
858
+ this.canDrop = true;
859
+ this.ensuredropPosition(dragRecords, droppedRecord);
715
860
  if (!tObj.rowDropSettings.targetID && this.canDrop && !isNullOrUndefined(args.rows[0])) {
716
861
  tObj.rowDragAndDropModule.updateIcon(args.rows, rowIdx, args);
717
862
  }
718
- if (isNullOrUndefined(tObj.rowDropSettings.targetID) && !this.canDrop) {
719
- this.removetopOrBottomBorder();
720
- }
721
863
  if (tObj.rowDropSettings.targetID) {
722
864
  var dropElement = parentsUntil(args.target, 'e-treegrid');
723
865
  if (dropElement && dropElement.id === this.parent.rowDropSettings.targetID) {
@@ -732,17 +874,26 @@ var RowDD = /** @class */ (function () {
732
874
  }
733
875
  }
734
876
  };
877
+ /**
878
+ * Handles the row drop event for the TreeGrid.
879
+ *
880
+ * @param {RowDropEventArgs} args - The event arguments for the row drop action.
881
+ * @returns {void} This function does not return a value.
882
+ */
735
883
  RowDD.prototype.rowDropped = function (args) {
736
884
  var tObj = this.parent;
737
885
  var parentItem = 'parentItem';
738
886
  if (!tObj.rowDropSettings.targetID) {
739
- if (parentsUntil(args.target, 'e-content')) {
887
+ if (parentsUntil(args.target, 'e-content') || (this.dropPosition === 'Invalid' || !this.canDrop)) {
740
888
  if (this.parent.element.querySelector('.e-errorelem')) {
741
889
  this.dropPosition = 'Invalid';
742
890
  }
743
891
  setValue('dropPosition', this.dropPosition, args);
744
892
  tObj.trigger(events.rowDrop, args);
745
893
  if (!args.cancel) {
894
+ if (!isCountRequired(this.parent) && this.dropPosition === 'Invalid') {
895
+ return;
896
+ }
746
897
  if (!isCountRequired(this.parent)) {
747
898
  this.dropRows(args);
748
899
  }
@@ -750,9 +901,7 @@ var RowDD = /** @class */ (function () {
750
901
  tObj.flatData = this.orderToIndex(tObj.flatData);
751
902
  }
752
903
  tObj.grid.refresh();
753
- if (!isNullOrUndefined(tObj.getHeaderContent().querySelector('.e-firstrow-border'))) {
754
- tObj.getHeaderContent().querySelector('.e-firstrow-border').remove();
755
- }
904
+ this.removeRowBorders();
756
905
  }
757
906
  }
758
907
  }
@@ -771,12 +920,7 @@ var RowDD = /** @class */ (function () {
771
920
  }
772
921
  this.removetopOrBottomBorder();
773
922
  this.removeChildBorder();
774
- if (!isNullOrUndefined(this.parent.element.getElementsByClassName('e-firstrow-border')[0])) {
775
- this.parent.element.getElementsByClassName('e-firstrow-border')[0].remove();
776
- }
777
- else if (!isNullOrUndefined(this.parent.element.getElementsByClassName('e-lastrow-border')[0])) {
778
- this.parent.element.getElementsByClassName('e-lastrow-border')[0].remove();
779
- }
923
+ this.removeRowBorders();
780
924
  if (this.parent.enableImmutableMode && !this.parent.allowPaging && !isNullOrUndefined(args.data[0]["" + parentItem])) {
781
925
  var index = this.parent.treeColumnIndex;
782
926
  index = index + 1;
@@ -818,6 +962,26 @@ var RowDD = /** @class */ (function () {
818
962
  }
819
963
  }
820
964
  };
965
+ /**
966
+ * Removes the border elements for the first and last rows of the TreeGrid.
967
+ *
968
+ * @returns {void} This function does not return a value.
969
+ */
970
+ RowDD.prototype.removeRowBorders = function () {
971
+ var _this = this;
972
+ ['e-firstrow-border', 'e-lastrow-border'].forEach(function (className) {
973
+ var element = _this.parent.element.getElementsByClassName(className)[0];
974
+ if (element) {
975
+ element.remove();
976
+ }
977
+ });
978
+ };
979
+ /**
980
+ * Handles the drag-and-drop operation between TreeGrids, updating the source and target grids.
981
+ *
982
+ * @param {RowDropEventArgs} args - The arguments related to the row drop event, including target information and data being dropped.
983
+ * @returns {void} - This function does not return any value.
984
+ */
821
985
  RowDD.prototype.dragDropGrid = function (args) {
822
986
  var tObj = this.parent;
823
987
  var targetRow = closest(args.target, 'tr');
@@ -878,9 +1042,22 @@ var RowDD = /** @class */ (function () {
878
1042
  srcControl.grid.refresh();
879
1043
  }
880
1044
  };
1045
+ /**
1046
+ * Retrieves the index of the target row based on its 'data-rowindex' attribute.
1047
+ *
1048
+ * @param {Element} targetRow - The target row element from which to retrieve the index.
1049
+ * @returns {number} - The index of the target row, or 0 if the targetRow is null or undefined.
1050
+ */
881
1051
  RowDD.prototype.getTargetIdx = function (targetRow) {
882
1052
  return targetRow ? parseInt(targetRow.getAttribute('data-rowindex'), 10) : 0;
883
1053
  };
1054
+ /**
1055
+ * Retrieves the parent data of a given record during a row drag-and-drop operation.
1056
+ *
1057
+ * @param {ITreeData} record - The record for which to retrieve the parent data.
1058
+ * @param {Object[]} [data] - Optional data array containing additional information related to the drop operation.
1059
+ * @returns {void} - This function does not return any value.
1060
+ */
884
1061
  RowDD.prototype.getParentData = function (record, data) {
885
1062
  var parentItem = record.parentItem;
886
1063
  var selectedItemIndex = -1;
@@ -908,6 +1085,13 @@ var RowDD = /** @class */ (function () {
908
1085
  }
909
1086
  }
910
1087
  };
1088
+ /**
1089
+ * Handles the row drop operation for the tree grid.
1090
+ *
1091
+ * @param {RowDropEventArgs} args - The event arguments containing details about the drop operation, including the target index and data.
1092
+ * @param {boolean} [isByMethod=false] - Optional flag indicating if the drop operation is triggered by a method.
1093
+ * @returns {void} - This function does not return any value.
1094
+ */
911
1095
  RowDD.prototype.dropRows = function (args, isByMethod) {
912
1096
  if (this.dropPosition !== 'Invalid' && !isRemoteData(this.parent)) {
913
1097
  var tObj = this.parent;
@@ -956,88 +1140,99 @@ var RowDD = /** @class */ (function () {
956
1140
  var _loop_1 = function (i) {
957
1141
  draggedRecord_2 = dragRecords[parseInt(i.toString(), 10)];
958
1142
  this_1.draggedRecord = draggedRecord_2;
959
- if (this_1.dropPosition !== 'Invalid' && !isNullOrUndefined(this_1.droppedRecord)) {
960
- if (!tObj.rowDropSettings.targetID || isByMethod) {
961
- this_1.deleteDragRow();
962
- }
963
- if (this_1.draggedRecord === this_1.droppedRecord) {
964
- var correctIndex = this_1.getTargetIdx(args.target.offsetParent.parentElement);
965
- if (isNaN(correctIndex)) {
966
- correctIndex = this_1.getTargetIdx(args.target.parentElement);
1143
+ if (!this_1.draggedRecord.hasChildRecords) {
1144
+ for (var _i = 0, dragRecords_2 = dragRecords; _i < dragRecords_2.length; _i++) {
1145
+ var dragRecord = dragRecords_2[_i];
1146
+ if (!isNullOrUndefined(dragRecord.childRecords) &&
1147
+ dragRecord.childRecords.indexOf(this_1.draggedRecord) !== -1) {
1148
+ this_1.draggedRecord = undefined;
967
1149
  }
968
- args.dropIndex = correctIndex;
969
- droppedRecord = this_1.droppedRecord = this_1.parent.getCurrentViewRecords()[args.dropIndex];
970
1150
  }
971
- if (droppedRecord.parentItem || this_1.dropPosition === 'middleSegment') {
972
- var parentRecords = tObj.parentData;
973
- var newParentIndex = parentRecords.indexOf(this_1.draggedRecord);
974
- if (newParentIndex !== -1) {
975
- parentRecords.splice(newParentIndex, 1);
1151
+ }
1152
+ if (!isNullOrUndefined(this_1.draggedRecord)) {
1153
+ if (this_1.dropPosition !== 'Invalid' && !isNullOrUndefined(this_1.droppedRecord)) {
1154
+ if (!tObj.rowDropSettings.targetID || isByMethod) {
1155
+ this_1.deleteDragRow();
976
1156
  }
977
- }
978
- var recordIndex1 = this_1.treeGridData.indexOf(droppedRecord);
979
- this_1.dropAtTop(recordIndex1);
980
- if (this_1.dropPosition === 'bottomSegment') {
981
- if (!droppedRecord.hasChildRecords) {
982
- if (this_1.parent.parentIdMapping) {
983
- this_1.treeData.splice(recordIndex1 + 1, 0, this_1.draggedRecord.taskData);
1157
+ if (this_1.draggedRecord === this_1.droppedRecord) {
1158
+ var correctIndex = this_1.getTargetIdx(args.target.offsetParent.parentElement);
1159
+ if (isNaN(correctIndex)) {
1160
+ correctIndex = this_1.getTargetIdx(args.target.parentElement);
984
1161
  }
985
- this_1.treeGridData.splice(recordIndex1 + 1, 0, this_1.draggedRecord);
1162
+ args.dropIndex = correctIndex;
1163
+ droppedRecord = this_1.droppedRecord = this_1.parent.getCurrentViewRecords()[args.dropIndex];
986
1164
  }
987
- else {
988
- count = this_1.getChildCount(droppedRecord, 0);
989
- if (this_1.parent.parentIdMapping) {
990
- this_1.treeData.splice(recordIndex1 + count + 1, 0, this_1.draggedRecord.taskData);
1165
+ if (droppedRecord.parentItem || this_1.dropPosition === 'middleSegment') {
1166
+ var parentRecords = tObj.parentData;
1167
+ var newParentIndex = parentRecords.indexOf(this_1.draggedRecord);
1168
+ if (newParentIndex !== -1) {
1169
+ parentRecords.splice(newParentIndex, 1);
991
1170
  }
992
- this_1.treeGridData.splice(recordIndex1 + count + 1, 0, this_1.draggedRecord);
993
1171
  }
994
- if (isNullOrUndefined(droppedRecord.parentItem)) {
995
- delete draggedRecord_2.parentItem;
996
- delete draggedRecord_2.parentUniqueID;
997
- draggedRecord_2.level = 0;
998
- if (this_1.parent.parentIdMapping) {
999
- draggedRecord_2[this_1.parent.parentIdMapping] = null;
1172
+ var recordIndex1 = this_1.treeGridData.indexOf(droppedRecord);
1173
+ this_1.dropAtTop(recordIndex1);
1174
+ if (this_1.dropPosition === 'bottomSegment') {
1175
+ if (!droppedRecord.hasChildRecords) {
1176
+ if (this_1.parent.parentIdMapping) {
1177
+ this_1.treeData.splice(recordIndex1 + 1, 0, this_1.draggedRecord.taskData);
1178
+ }
1179
+ this_1.treeGridData.splice(recordIndex1 + 1, 0, this_1.draggedRecord);
1000
1180
  }
1001
- }
1002
- if (droppedRecord.parentItem) {
1003
- var rec = this_1.getChildrecordsByParentID(droppedRecord.parentUniqueID);
1004
- var childRecords = rec[0].childRecords;
1005
- var droppedRecordIndex = childRecords.indexOf(droppedRecord) + 1;
1006
- childRecords.splice(droppedRecordIndex, 0, draggedRecord_2);
1007
- draggedRecord_2.parentItem = droppedRecord.parentItem;
1008
- draggedRecord_2.parentUniqueID = droppedRecord.parentUniqueID;
1009
- draggedRecord_2.level = droppedRecord.level;
1010
- if (this_1.parent.parentIdMapping) {
1011
- draggedRecord_2[this_1.parent.parentIdMapping] = droppedRecord[this_1.parent.parentIdMapping];
1181
+ else {
1182
+ count = this_1.getChildCount(droppedRecord, 0);
1183
+ if (this_1.parent.parentIdMapping) {
1184
+ this_1.treeData.splice(recordIndex1 + count + 1, 0, this_1.draggedRecord.taskData);
1185
+ }
1186
+ this_1.treeGridData.splice(recordIndex1 + count + 1, 0, this_1.draggedRecord);
1187
+ }
1188
+ if (isNullOrUndefined(droppedRecord.parentItem)) {
1189
+ delete draggedRecord_2.parentItem;
1190
+ delete draggedRecord_2.parentUniqueID;
1191
+ draggedRecord_2.level = 0;
1192
+ if (this_1.parent.parentIdMapping) {
1193
+ draggedRecord_2[this_1.parent.parentIdMapping] = null;
1194
+ }
1195
+ }
1196
+ if (droppedRecord.parentItem) {
1197
+ var rec = this_1.getChildrecordsByParentID(droppedRecord.parentUniqueID);
1198
+ var childRecords = rec[0].childRecords;
1199
+ var droppedRecordIndex = childRecords.indexOf(droppedRecord) + 1;
1200
+ childRecords.splice(droppedRecordIndex, 0, draggedRecord_2);
1012
1201
  draggedRecord_2.parentItem = droppedRecord.parentItem;
1202
+ draggedRecord_2.parentUniqueID = droppedRecord.parentUniqueID;
1013
1203
  draggedRecord_2.level = droppedRecord.level;
1204
+ if (this_1.parent.parentIdMapping) {
1205
+ draggedRecord_2[this_1.parent.parentIdMapping] = droppedRecord[this_1.parent.parentIdMapping];
1206
+ draggedRecord_2.parentItem = droppedRecord.parentItem;
1207
+ draggedRecord_2.level = droppedRecord.level;
1208
+ }
1209
+ }
1210
+ if (draggedRecord_2.hasChildRecords) {
1211
+ var level = 1;
1212
+ this_1.updateChildRecordLevel(draggedRecord_2, level);
1213
+ this_1.updateChildRecord(draggedRecord_2, recordIndex1 + count + 1);
1014
1214
  }
1015
1215
  }
1016
- if (draggedRecord_2.hasChildRecords) {
1017
- var level = 1;
1018
- this_1.updateChildRecordLevel(draggedRecord_2, level);
1019
- this_1.updateChildRecord(draggedRecord_2, recordIndex1 + count + 1);
1020
- }
1216
+ this_1.dropMiddle(recordIndex1);
1021
1217
  }
1022
- this_1.dropMiddle(recordIndex1);
1023
- }
1024
- if (isNullOrUndefined(draggedRecord_2.parentItem)) {
1025
- var parentRecords = tObj.parentData;
1026
- var newParentIndex = parentRecords.indexOf(this_1.droppedRecord);
1027
- var nonRepeat_1 = 0;
1028
- parentRecords.filter(function (e) {
1029
- if (draggedRecord_2.uniqueID === e.uniqueID) {
1030
- nonRepeat_1++;
1218
+ if (isNullOrUndefined(draggedRecord_2.parentItem)) {
1219
+ var parentRecords = tObj.parentData;
1220
+ var newParentIndex = parentRecords.indexOf(this_1.droppedRecord);
1221
+ var nonRepeat_1 = 0;
1222
+ parentRecords.filter(function (e) {
1223
+ if (draggedRecord_2.uniqueID === e.uniqueID) {
1224
+ nonRepeat_1++;
1225
+ }
1226
+ });
1227
+ if (this_1.dropPosition === 'bottomSegment' && nonRepeat_1 === 0) {
1228
+ parentRecords.splice(newParentIndex + 1, 0, draggedRecord_2);
1229
+ }
1230
+ else if (this_1.dropPosition === 'topSegment' && nonRepeat_1 === 0) {
1231
+ parentRecords.splice(newParentIndex, 0, draggedRecord_2);
1031
1232
  }
1032
- });
1033
- if (this_1.dropPosition === 'bottomSegment' && nonRepeat_1 === 0) {
1034
- parentRecords.splice(newParentIndex + 1, 0, draggedRecord_2);
1035
- }
1036
- else if (this_1.dropPosition === 'topSegment' && nonRepeat_1 === 0) {
1037
- parentRecords.splice(newParentIndex, 0, draggedRecord_2);
1038
1233
  }
1234
+ tObj.rowDragAndDropModule.refreshGridDataSource();
1039
1235
  }
1040
- tObj.rowDragAndDropModule.refreshGridDataSource();
1041
1236
  };
1042
1237
  var this_1 = this;
1043
1238
  for (var i = 0; i < dragLength; i++) {
@@ -1045,6 +1240,12 @@ var RowDD = /** @class */ (function () {
1045
1240
  }
1046
1241
  }
1047
1242
  };
1243
+ /**
1244
+ * Handles the logic for inserting a dragged record into the middle of a parent record's child records.
1245
+ *
1246
+ * @param {number} recordIndex - The index at which to insert the dragged record relative to the parent record's child records.
1247
+ * @returns {void} - This function does not return any value.
1248
+ */
1048
1249
  RowDD.prototype.dropMiddle = function (recordIndex) {
1049
1250
  var tObj = this.parent;
1050
1251
  var childRecords = findChildrenRecords(this.droppedRecord);
@@ -1065,15 +1266,23 @@ var RowDD = /** @class */ (function () {
1065
1266
  }
1066
1267
  }
1067
1268
  };
1269
+ /**
1270
+ * Handles the logic for inserting a dragged record at the top of a parent record's child records.
1271
+ *
1272
+ * @param {number} recordIndex1 - The index at which to insert the dragged record in the tree grid data.
1273
+ * @returns {void} - This function does not return any value.
1274
+ */
1068
1275
  RowDD.prototype.dropAtTop = function (recordIndex1) {
1069
1276
  var tObj = this.parent;
1070
1277
  if (this.dropPosition === 'topSegment') {
1071
1278
  if (tObj.parentIdMapping) {
1072
1279
  this.treeData.splice(recordIndex1, 0, this.draggedRecord.taskData);
1073
1280
  }
1074
- this.draggedRecord.parentItem = this.treeGridData[parseInt(recordIndex1.toString(), 10)].parentItem;
1075
- this.draggedRecord.parentUniqueID = this.treeGridData[parseInt(recordIndex1.toString(), 10)].parentUniqueID;
1076
- this.draggedRecord.level = this.treeGridData[parseInt(recordIndex1.toString(), 10)].level;
1281
+ var targetRecord = this.treeGridData[parseInt(recordIndex1.toString(), 10)];
1282
+ this.draggedRecord.parentItem = targetRecord.parentItem;
1283
+ this.draggedRecord.parentUniqueID = targetRecord.parentUniqueID;
1284
+ this.draggedRecord.level = targetRecord.level;
1285
+ // Insert dragged record into the grid data
1077
1286
  this.treeGridData.splice(parseInt(recordIndex1.toString(), 10), 0, this.draggedRecord);
1078
1287
  if (this.draggedRecord.hasChildRecords) {
1079
1288
  var level = 1;
@@ -1084,10 +1293,16 @@ var RowDD = /** @class */ (function () {
1084
1293
  var rec = this.getChildrecordsByParentID(this.droppedRecord.parentUniqueID);
1085
1294
  var childRecords = rec[0].childRecords;
1086
1295
  var droppedRecordIndex = childRecords.indexOf(this.droppedRecord);
1296
+ // Insert the dragged record into the child records at the appropriate position
1087
1297
  childRecords.splice(droppedRecordIndex, 0, this.draggedRecord);
1088
1298
  }
1089
1299
  }
1090
1300
  };
1301
+ /**
1302
+ * Updates the level and hierarchy of the dragged record based on the drop position.
1303
+ *
1304
+ * @returns {void} - This function does not return any value.
1305
+ */
1091
1306
  RowDD.prototype.recordLevel = function () {
1092
1307
  var tObj = this.parent;
1093
1308
  var draggedRecord = this.draggedRecord;
@@ -1109,6 +1324,7 @@ var RowDD = /** @class */ (function () {
1109
1324
  draggedRecord.parentItem = parentItem;
1110
1325
  draggedRecord.parentUniqueID = droppedRecord.uniqueID;
1111
1326
  droppedRecord.childRecords.splice(droppedRecord.childRecords.length, 0, draggedRecord);
1327
+ setValue('uniqueIDCollection.' + draggedRecord.uniqueID, draggedRecord, tObj);
1112
1328
  var isSelfReference = 'isSelfReference';
1113
1329
  if (tObj["" + isSelfReference]) {
1114
1330
  droppedRecord[tObj.childMapping] = [];
@@ -1128,6 +1344,11 @@ var RowDD = /** @class */ (function () {
1128
1344
  droppedRecord.expanded = true;
1129
1345
  }
1130
1346
  };
1347
+ /**
1348
+ * Deletes the currently dragged row from the TreeGrid.
1349
+ *
1350
+ * @returns {void} - This function does not return any value.
1351
+ */
1131
1352
  RowDD.prototype.deleteDragRow = function () {
1132
1353
  if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
1133
1354
  this.treeGridData = this.parent.grid.dataSource.dataSource.json;
@@ -1143,6 +1364,13 @@ var RowDD = /** @class */ (function () {
1143
1364
  }
1144
1365
  this.removeRecords(deletedRow);
1145
1366
  };
1367
+ /**
1368
+ * Updates the child records of a specified parent record in the TreeGrid.
1369
+ *
1370
+ * @param {ITreeData} record - The parent record whose child records will be updated.
1371
+ * @param {number} count - The initial count to keep track of record positioning.
1372
+ * @returns {number} - The updated count after processing all child records.
1373
+ */
1146
1374
  RowDD.prototype.updateChildRecord = function (record, count) {
1147
1375
  var currentRecord;
1148
1376
  var tObj = this.parent;
@@ -1170,6 +1398,13 @@ var RowDD = /** @class */ (function () {
1170
1398
  }
1171
1399
  return count;
1172
1400
  };
1401
+ /**
1402
+ * Updates the level of child records for a specified parent record in the TreeGrid.
1403
+ *
1404
+ * @param {ITreeData} record - The parent record whose child records' levels will be updated.
1405
+ * @param {number} level - The current level of the parent record.
1406
+ * @returns {number} - The updated level after processing all child records.
1407
+ */
1173
1408
  RowDD.prototype.updateChildRecordLevel = function (record, level) {
1174
1409
  var length = 0;
1175
1410
  var currentRecord;
@@ -1200,6 +1435,12 @@ var RowDD = /** @class */ (function () {
1200
1435
  }
1201
1436
  return level;
1202
1437
  };
1438
+ /**
1439
+ * Removes specified records from the TreeGrid data source.
1440
+ *
1441
+ * @param {ITreeData} record - The record to be removed, including any child records if applicable.
1442
+ * @returns {void} - This method does not return a value.
1443
+ */
1203
1444
  RowDD.prototype.removeRecords = function (record) {
1204
1445
  var tObj = this.parent;
1205
1446
  var dataSource;
@@ -1282,6 +1523,12 @@ var RowDD = /** @class */ (function () {
1282
1523
  }
1283
1524
  }
1284
1525
  };
1526
+ /**
1527
+ * Updates the records in the TreeGrid data source that have been modified.
1528
+ *
1529
+ * @param {ITreeData} record - The record to update, along with its parent records if applicable.
1530
+ * @returns {void} - This method does not return a value.
1531
+ */
1285
1532
  RowDD.prototype.updateModifiedRecords = function (record) {
1286
1533
  var parentData = getParentData(this.parent, record.parentUniqueID);
1287
1534
  if (!isNullOrUndefined(parentData)) {
@@ -1289,6 +1536,12 @@ var RowDD = /** @class */ (function () {
1289
1536
  this.updateModifiedRecords(parentData);
1290
1537
  }
1291
1538
  };
1539
+ /**
1540
+ * Recursively removes child records from the specified record and updates the data source.
1541
+ *
1542
+ * @param {ITreeData} record - The parent record whose child records are to be removed.
1543
+ * @returns {void} - This method does not return a value.
1544
+ */
1292
1545
  RowDD.prototype.removeChildItem = function (record) {
1293
1546
  var currentRecord;
1294
1547
  var idx;
@@ -1335,6 +1588,13 @@ var RowDD = /** @class */ (function () {
1335
1588
  }
1336
1589
  }
1337
1590
  };
1591
+ /**
1592
+ * Retrieves the count of child records associated with the specified parent record.
1593
+ *
1594
+ * @param {ITreeData} record - The parent record for which child count is to be calculated.
1595
+ * @param {number} count - The initial count to start with, usually passed as 0.
1596
+ * @returns {number} - The total count of child records.
1597
+ */
1338
1598
  RowDD.prototype.getChildCount = function (record, count) {
1339
1599
  var currentRecord;
1340
1600
  if (!record.hasChildRecords) {
@@ -1349,6 +1609,14 @@ var RowDD = /** @class */ (function () {
1349
1609
  }
1350
1610
  return count;
1351
1611
  };
1612
+ /**
1613
+ * Ensures the validity of the drop position for the dragged records by verifying the hierarchy and position constraints.
1614
+ * If the current record is found in the dragged records' children, sets the drop position to 'Invalid'.
1615
+ *
1616
+ * @param {ITreeData[]} draggedRecords - The array of dragged records being verified.
1617
+ * @param {ITreeData} currentRecord - The current record to check against dragged records.
1618
+ * @returns {void} - This function does not return a value.
1619
+ */
1352
1620
  RowDD.prototype.ensuredropPosition = function (draggedRecords, currentRecord) {
1353
1621
  var _this = this;
1354
1622
  draggedRecords.filter(function (e) {
@@ -1361,11 +1629,29 @@ var RowDD = /** @class */ (function () {
1361
1629
  _this.dropPosition = 'Invalid';
1362
1630
  _this.addErrorElem();
1363
1631
  _this.canDrop = false;
1632
+ if (isNullOrUndefined(_this.parent.rowDropSettings.targetID)) {
1633
+ _this.removetopOrBottomBorder();
1634
+ _this.removeChildBorder();
1635
+ }
1364
1636
  return;
1365
1637
  }
1366
1638
  }
1367
1639
  });
1368
1640
  };
1641
+ RowDD.prototype.isDuplicateData = function (currentData) {
1642
+ var primaryKeys = this.parent.getPrimaryKeyFieldNames();
1643
+ if (primaryKeys.length === 0) {
1644
+ return false;
1645
+ }
1646
+ return this.parent.flatData.some(function (data) {
1647
+ // eslint-disable-next-line
1648
+ return primaryKeys.every(function (key) { return data[key] === currentData[key]; });
1649
+ });
1650
+ };
1651
+ /**
1652
+ * Cleans up resources, event listeners, and DOM elements when the TreeGrid component is destroyed.
1653
+ * @returns {void}
1654
+ */
1369
1655
  RowDD.prototype.destroy = function () {
1370
1656
  this.removeEventListener();
1371
1657
  };