@syncfusion/ej2-treegrid 27.2.2 → 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.
- package/README.md +2 -2
- package/dist/ej2-treegrid.min.js +3 -3
- package/dist/ej2-treegrid.umd.min.js +3 -3
- package/dist/ej2-treegrid.umd.min.js.map +1 -1
- package/dist/es6/ej2-treegrid.es2015.js +576 -256
- package/dist/es6/ej2-treegrid.es2015.js.map +1 -1
- package/dist/es6/ej2-treegrid.es5.js +580 -256
- package/dist/es6/ej2-treegrid.es5.js.map +1 -1
- package/dist/global/ej2-treegrid.min.js +3 -3
- package/dist/global/ej2-treegrid.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +10 -10
- package/src/treegrid/actions/batch-edit.js +58 -56
- package/src/treegrid/actions/context-menu.js +3 -1
- package/src/treegrid/actions/reorder.d.ts +1 -1
- package/src/treegrid/actions/reorder.js +5 -17
- package/src/treegrid/actions/rowdragdrop.d.ts +286 -14
- package/src/treegrid/actions/rowdragdrop.js +447 -161
- package/src/treegrid/actions/virtual-scroll.js +5 -0
- package/src/treegrid/base/data.js +22 -5
- package/src/treegrid/base/treegrid.d.ts +1 -0
- package/src/treegrid/base/treegrid.js +27 -10
- package/src/treegrid/renderer/virtual-tree-content-render.js +14 -7
- package/styles/bds-lite.css +703 -0
- package/styles/bds-lite.scss +18 -0
- package/styles/bds.css +723 -0
- package/styles/bds.scss +19 -0
- package/styles/bootstrap-dark-lite.css +20 -0
- package/styles/bootstrap-dark.css +26 -6
- package/styles/bootstrap-lite.css +20 -0
- package/styles/bootstrap.css +26 -6
- package/styles/bootstrap4-lite.css +20 -0
- package/styles/bootstrap4.css +26 -6
- package/styles/bootstrap5-dark-lite.css +20 -0
- package/styles/bootstrap5-dark.css +26 -6
- package/styles/bootstrap5-lite.css +20 -0
- package/styles/bootstrap5.3-lite.css +20 -0
- package/styles/bootstrap5.3.css +26 -6
- package/styles/bootstrap5.css +26 -6
- package/styles/fabric-dark-lite.css +20 -0
- package/styles/fabric-dark.css +26 -6
- package/styles/fabric-lite.css +20 -0
- package/styles/fabric.css +26 -6
- package/styles/fluent-dark-lite.css +20 -0
- package/styles/fluent-dark.css +27 -7
- package/styles/fluent-lite.css +20 -0
- package/styles/fluent.css +27 -7
- package/styles/fluent2-lite.css +20 -0
- package/styles/fluent2.css +28 -8
- package/styles/highcontrast-light-lite.css +20 -0
- package/styles/highcontrast-light.css +26 -6
- package/styles/highcontrast-lite.css +21 -1
- package/styles/highcontrast.css +28 -8
- package/styles/material-dark-lite.css +20 -0
- package/styles/material-dark.css +26 -6
- package/styles/material-lite.css +20 -0
- package/styles/material.css +26 -6
- package/styles/material3-dark-lite.css +20 -0
- package/styles/material3-dark.css +26 -6
- package/styles/material3-lite.css +20 -0
- package/styles/material3.css +26 -6
- package/styles/tailwind-dark-lite.css +20 -0
- package/styles/tailwind-dark.css +26 -6
- package/styles/tailwind-lite.css +20 -0
- package/styles/tailwind.css +26 -6
- package/styles/tailwind3-lite.css +511 -0
- package/styles/tailwind3-lite.scss +18 -0
- package/styles/tailwind3.css +531 -0
- package/styles/tailwind3.scss +19 -0
- package/styles/treegrid/_bigger.scss +45 -41
- package/styles/treegrid/_layout.scss +23 -2
- package/styles/treegrid/_tailwind3-definition.scss +24 -0
- package/styles/treegrid/bds.css +723 -0
- package/styles/treegrid/bds.scss +19 -0
- package/styles/treegrid/bootstrap-dark.css +26 -6
- package/styles/treegrid/bootstrap.css +26 -6
- package/styles/treegrid/bootstrap4.css +26 -6
- package/styles/treegrid/bootstrap5-dark.css +26 -6
- package/styles/treegrid/bootstrap5.3.css +26 -6
- package/styles/treegrid/bootstrap5.css +26 -6
- package/styles/treegrid/fabric-dark.css +26 -6
- package/styles/treegrid/fabric.css +26 -6
- package/styles/treegrid/fluent-dark.css +27 -7
- package/styles/treegrid/fluent.css +27 -7
- package/styles/treegrid/fluent2.css +28 -8
- package/styles/treegrid/highcontrast-light.css +26 -6
- package/styles/treegrid/highcontrast.css +28 -8
- package/styles/treegrid/icons/_tailwind3.scss +37 -0
- package/styles/treegrid/material-dark.css +26 -6
- package/styles/treegrid/material.css +26 -6
- package/styles/treegrid/material3-dark.css +26 -6
- package/styles/treegrid/material3.css +26 -6
- package/styles/treegrid/tailwind-dark.css +26 -6
- package/styles/treegrid/tailwind.css +26 -6
- package/styles/treegrid/tailwind3.css +531 -0
- package/styles/treegrid/tailwind3.scss +19 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { merge, Property, ChildProperty, Collection, isNullOrUndefined, Browser, removeClass, addClass, getValue, createElement, setValue, extend as extend$1, Internationalization, getEnumValue, compile, Component, L10n, EventHandler, KeyboardEvents, SanitizeHtmlHelper, Complex, Event, NotifyPropertyChanges, closest,
|
|
1
|
+
import { merge, Property, ChildProperty, Collection, isNullOrUndefined, Browser, removeClass, addClass, getValue, createElement, setValue, extend as extend$1, Internationalization, getEnumValue, compile, Component, L10n, EventHandler, KeyboardEvents, SanitizeHtmlHelper, Complex, Event, NotifyPropertyChanges, closest, setStyleAttribute, select, classList, debounce, remove } from '@syncfusion/ej2-base';
|
|
2
2
|
import { Logger as Logger$1, Grid, detailLists, Clipboard, getObject, parentsUntil, Print as Print$1, templateCompiler, appendChildren, extend, CellRenderer, getUid, CellType, Freeze as Freeze$1, getNumberFormat, getActualProperties, iterateArrayOrObject, RowDropSettings as RowDropSettings$1, Reorder as Reorder$1, Resize as Resize$1, RowDD as RowDD$1, Scroll, VirtualRowModelGenerator, Filter as Filter$1, ExcelExport as ExcelExport$1, Data, ExportHelper, PdfExport as PdfExport$1, Page as Page$1, Toolbar as Toolbar$1, Aggregate as Aggregate$1, calculateAggregate, Sort as Sort$1, ColumnMenu as ColumnMenu$1, ContextMenu as ContextMenu$1, Edit as Edit$1, resetRowIndex, CommandColumn as CommandColumn$1, DetailRow as DetailRow$1, VirtualContentRenderer, Cell, InterSectionObserver, getTransformValues, VirtualScroll as VirtualScroll$1, RenderType, VirtualHeaderRenderer, ColumnChooser as ColumnChooser$1, InfiniteScroll as InfiniteScroll$1, RowRenderer } from '@syncfusion/ej2-grids';
|
|
3
3
|
import { createCheckBox } from '@syncfusion/ej2-buttons';
|
|
4
4
|
import { DataManager, ODataAdaptor, WebApiAdaptor, WebMethodAdaptor, CacheAdaptor, UrlAdaptor, Query, DataUtil, RemoteSaveAdaptor, Deferred, JsonAdaptor, Predicate as Predicate$1 } from '@syncfusion/ej2-data';
|
|
@@ -2117,9 +2117,15 @@ class DataManipulation {
|
|
|
2117
2117
|
records[parseInt(rec.toString(), 10)].taskData = extend$1({}, records[parseInt(rec.toString(), 10)]);
|
|
2118
2118
|
records[parseInt(rec.toString(), 10)].uniqueID = getUid(this.parent.element.id + '_data_');
|
|
2119
2119
|
setValue('uniqueIDCollection.' + records[parseInt(rec.toString(), 10)].uniqueID, records[parseInt(rec.toString(), 10)], this.parent);
|
|
2120
|
-
records[parseInt(rec.toString(), 10)].level
|
|
2121
|
-
|
|
2122
|
-
|
|
2120
|
+
if (isRemoteData(this.parent) && this.parent.enableVirtualization && records[parseInt(rec.toString(), 10)][`${this.parent.parentIdMapping}`] && (isNullOrUndefined(records[parseInt(rec.toString(), 10)].level) || records[parseInt(rec.toString(), 10)].level === 0)) {
|
|
2121
|
+
const parentID = records[parseInt(rec.toString(), 10)][`${this.parent.parentIdMapping}`];
|
|
2122
|
+
const parentRec = records.find((record) => record[`${this.parent.idMapping}`] === parentID);
|
|
2123
|
+
if (parentRec) {
|
|
2124
|
+
records[parseInt(rec.toString(), 10)].level = parentRec.level + 1;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
records[parseInt(rec.toString(), 10)].level = 0;
|
|
2123
2129
|
}
|
|
2124
2130
|
records[parseInt(rec.toString(), 10)].index = Math.ceil(Math.random() * 1000);
|
|
2125
2131
|
if ((records[parseInt(rec.toString(), 10)][this.parent.hasChildMapping] ||
|
|
@@ -2318,7 +2324,7 @@ class DataManipulation {
|
|
|
2318
2324
|
const parentData = this.parent[`${remoteExpandedData}`][parseInt(i.toString(), 10)];
|
|
2319
2325
|
delete parentData.childRecords;
|
|
2320
2326
|
result[parseInt(r.toString(), 10)].parentItem = parentData;
|
|
2321
|
-
result[parseInt(r.toString(), 10)].parentUniqueID =
|
|
2327
|
+
result[parseInt(r.toString(), 10)].parentUniqueID = parentData.uniqueID;
|
|
2322
2328
|
}
|
|
2323
2329
|
}
|
|
2324
2330
|
}
|
|
@@ -2353,6 +2359,9 @@ class DataManipulation {
|
|
|
2353
2359
|
}
|
|
2354
2360
|
result[parseInt(r.toString(), 10)].index = Math.ceil(Math.random() * 1000);
|
|
2355
2361
|
result[parseInt(r.toString(), 10)].uniqueID = getUid(this.parent.element.id + '_data_');
|
|
2362
|
+
if (rowDetails.record[`${this.parent.idMapping}`] === result[parseInt(r.toString(), 10)][`${this.parent.idMapping}`]) {
|
|
2363
|
+
rowDetails.record.uniqueID = result[parseInt(r.toString(), 10)].uniqueID;
|
|
2364
|
+
}
|
|
2356
2365
|
result[parseInt(r.toString(), 10)].checkboxState = 'uncheck';
|
|
2357
2366
|
if (this.parent.enableVirtualization && isNullOrUndefined(result[parseInt(r.toString(), 10)].level)) {
|
|
2358
2367
|
for (let p = 0; p < this.parent.grid.currentViewData.length; p++) {
|
|
@@ -2541,7 +2550,14 @@ class DataManipulation {
|
|
|
2541
2550
|
this.parent.flatData.push(currentData);
|
|
2542
2551
|
}
|
|
2543
2552
|
else if (isNullOrUndefined(currentData[`${this.parent.parentIdMapping}`]) || currentData.parentItem) {
|
|
2544
|
-
this.parent.
|
|
2553
|
+
if (!isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
|
|
2554
|
+
if (!this.parent.rowDragAndDropModule['isDuplicateData'](currentData)) {
|
|
2555
|
+
this.parent.flatData.push(currentData);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
else {
|
|
2559
|
+
this.parent.flatData.push(currentData);
|
|
2560
|
+
}
|
|
2545
2561
|
this.parent['infiniteScrollData'].push(currentData);
|
|
2546
2562
|
}
|
|
2547
2563
|
if (!this.isSelfReference && currentData.level === 0) {
|
|
@@ -3928,7 +3944,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
3928
3944
|
requiredModules() {
|
|
3929
3945
|
const modules = [];
|
|
3930
3946
|
const splitFrozenCount = 'splitFrozenCount';
|
|
3931
|
-
if (
|
|
3947
|
+
if (isNullOrUndefined(this['changedProperties'].columns)) {
|
|
3932
3948
|
this.grid[`${splitFrozenCount}`](this.getColumns());
|
|
3933
3949
|
}
|
|
3934
3950
|
if (this.isDestroyed) {
|
|
@@ -4428,7 +4444,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
4428
4444
|
if (this.pageSettings.pageSizeMode === 'Root') {
|
|
4429
4445
|
this.grid.selectionModule['totalRecordsCount'] = this.grid.currentViewData.length;
|
|
4430
4446
|
}
|
|
4431
|
-
|
|
4447
|
+
if (!args.cancel) {
|
|
4448
|
+
this.trigger(rowSelecting, args);
|
|
4449
|
+
}
|
|
4432
4450
|
};
|
|
4433
4451
|
this.grid.rowDeselecting = (args) => {
|
|
4434
4452
|
this.IsExpandCollapseClicked(args);
|
|
@@ -5189,11 +5207,8 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
5189
5207
|
onPropertyChanged(newProp) {
|
|
5190
5208
|
const properties = Object.keys(newProp);
|
|
5191
5209
|
let requireRefresh = false;
|
|
5192
|
-
if (properties.indexOf('columns') > -1 && !isNullOrUndefined(newProp.columns)
|
|
5193
|
-
|
|
5194
|
-
this.grid.columns = this.getGridColumns(newProp.columns);
|
|
5195
|
-
this.grid['updateColumnObject']();
|
|
5196
|
-
requireRefresh = true;
|
|
5210
|
+
if (properties.indexOf('columns') > -1 && !isNullOrUndefined(newProp.columns)) {
|
|
5211
|
+
this.refreshColumns();
|
|
5197
5212
|
}
|
|
5198
5213
|
for (const prop of properties) {
|
|
5199
5214
|
switch (prop) {
|
|
@@ -6241,12 +6256,28 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
6241
6256
|
refreshColumns(refreshUI) {
|
|
6242
6257
|
if (isNullOrUndefined(refreshUI) || refreshUI) {
|
|
6243
6258
|
this.grid.columns = this.getGridColumns(this.columns);
|
|
6259
|
+
this.getTreeColumn();
|
|
6244
6260
|
this.grid.refreshColumns();
|
|
6245
6261
|
}
|
|
6246
6262
|
else {
|
|
6247
6263
|
this.grid.setProperties({ columns: this.getGridColumns(this.columns) }, true);
|
|
6248
6264
|
}
|
|
6249
6265
|
}
|
|
6266
|
+
getTreeColumn() {
|
|
6267
|
+
const columnModel = 'columnModel';
|
|
6268
|
+
const treeColumn = this[`${columnModel}`][this.treeColumnIndex];
|
|
6269
|
+
let treeIndex;
|
|
6270
|
+
const updatedCols = this.getColumns();
|
|
6271
|
+
for (let f = 0; f < updatedCols.length; f++) {
|
|
6272
|
+
const treeColumnfield = getObject('field', treeColumn);
|
|
6273
|
+
const parentColumnfield = getObject('field', updatedCols[parseInt(f.toString(), 10)]);
|
|
6274
|
+
if (treeColumnfield === parentColumnfield) {
|
|
6275
|
+
treeIndex = f;
|
|
6276
|
+
break;
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
this.setProperties({ treeColumnIndex: treeIndex }, true);
|
|
6280
|
+
}
|
|
6250
6281
|
/**
|
|
6251
6282
|
* Refreshes the TreeGrid header.
|
|
6252
6283
|
*
|
|
@@ -7036,7 +7067,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
7036
7067
|
this.toggleRowVisibility(freezeRightRows[parseInt(i.toString(), 10)], displayAction);
|
|
7037
7068
|
}
|
|
7038
7069
|
this.notify('childRowExpand', { row: rows[parseInt(i.toString(), 10)] });
|
|
7039
|
-
if ((!isNullOrUndefined(childRecords[parseInt(i.toString(), 10)].childRecords) && childRecords[parseInt(i.toString(), 10)].childRecords.length > 0) && (action !== 'expand' ||
|
|
7070
|
+
if ((!isNullOrUndefined(childRecords)) && (!isNullOrUndefined(childRecords[parseInt(i.toString(), 10)].childRecords) && childRecords[parseInt(i.toString(), 10)].childRecords.length > 0) && (action !== 'expand' ||
|
|
7040
7071
|
isNullOrUndefined(childRecords[parseInt(i.toString(), 10)].expanded) || childRecords[parseInt(i.toString(), 10)].expanded)) {
|
|
7041
7072
|
this.expandCollapse(action, rows[parseInt(i.toString(), 10)], childRecords[parseInt(i.toString(), 10)], true);
|
|
7042
7073
|
if (this.frozenColumns <= this.treeColumnIndex && !isNullOrUndefined(movableRows)) {
|
|
@@ -7058,7 +7089,7 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
7058
7089
|
}
|
|
7059
7090
|
toggleRowVisibility(row, displayAction) {
|
|
7060
7091
|
if (row) {
|
|
7061
|
-
row.classList.remove('e-childrow-hidden', 'e-childrow-visible');
|
|
7092
|
+
row.classList.remove('e-childrow-hidden', 'e-childrow-visible', 'e-hide');
|
|
7062
7093
|
row.classList.add(displayAction);
|
|
7063
7094
|
}
|
|
7064
7095
|
}
|
|
@@ -7559,7 +7590,9 @@ let TreeGrid = TreeGrid_1 = class TreeGrid extends Component {
|
|
|
7559
7590
|
* @returns {void}
|
|
7560
7591
|
*/
|
|
7561
7592
|
reorderRows(fromIndexes, toIndex, position) {
|
|
7562
|
-
this.rowDragAndDropModule
|
|
7593
|
+
if (!isNullOrUndefined(this.rowDragAndDropModule)) {
|
|
7594
|
+
this.rowDragAndDropModule.reorderRows(fromIndexes, toIndex, position);
|
|
7595
|
+
}
|
|
7563
7596
|
}
|
|
7564
7597
|
/**
|
|
7565
7598
|
* Indents the record to one level of hierarchy. Moves the selected row as the last child of its previous row.
|
|
@@ -8013,13 +8046,13 @@ class Reorder {
|
|
|
8013
8046
|
* @returns {void}
|
|
8014
8047
|
*/
|
|
8015
8048
|
addEventListener() {
|
|
8016
|
-
this.parent.on('getColumnIndex', this.
|
|
8049
|
+
this.parent.on('getColumnIndex', this.updateTreeColumn, this);
|
|
8017
8050
|
}
|
|
8018
8051
|
removeEventListener() {
|
|
8019
8052
|
if (this.parent.isDestroyed) {
|
|
8020
8053
|
return;
|
|
8021
8054
|
}
|
|
8022
|
-
this.parent.off('getColumnIndex', this.
|
|
8055
|
+
this.parent.off('getColumnIndex', this.updateTreeColumn);
|
|
8023
8056
|
}
|
|
8024
8057
|
/**
|
|
8025
8058
|
* To destroy the Reorder
|
|
@@ -8030,20 +8063,8 @@ class Reorder {
|
|
|
8030
8063
|
destroy() {
|
|
8031
8064
|
this.removeEventListener();
|
|
8032
8065
|
}
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
const treeColumn = this.parent[`${columnModel}`][this.parent.treeColumnIndex];
|
|
8036
|
-
let treeIndex;
|
|
8037
|
-
const updatedCols = this.parent.getColumns();
|
|
8038
|
-
for (let f = 0; f < updatedCols.length; f++) {
|
|
8039
|
-
const treeColumnfield = getObject('field', treeColumn);
|
|
8040
|
-
const parentColumnfield = getObject('field', updatedCols[parseInt(f.toString(), 10)]);
|
|
8041
|
-
if (treeColumnfield === parentColumnfield) {
|
|
8042
|
-
treeIndex = f;
|
|
8043
|
-
break;
|
|
8044
|
-
}
|
|
8045
|
-
}
|
|
8046
|
-
this.parent.setProperties({ treeColumnIndex: treeIndex }, true);
|
|
8066
|
+
updateTreeColumn() {
|
|
8067
|
+
this.parent['getTreeColumn']();
|
|
8047
8068
|
}
|
|
8048
8069
|
}
|
|
8049
8070
|
|
|
@@ -8106,24 +8127,44 @@ class RowDD {
|
|
|
8106
8127
|
* @param {TreeGrid} parent - Tree Grid instance
|
|
8107
8128
|
*/
|
|
8108
8129
|
constructor(parent) {
|
|
8109
|
-
/** @hidden
|
|
8130
|
+
/** @hidden
|
|
8131
|
+
* Indicates whether a row can be dropped into the current target position during a drag-and-drop operation.
|
|
8132
|
+
*/
|
|
8110
8133
|
this.canDrop = true;
|
|
8111
|
-
/** @hidden
|
|
8134
|
+
/** @hidden
|
|
8135
|
+
* Indicates whether the current drag operation includes child records of the dragged item.
|
|
8136
|
+
*/
|
|
8112
8137
|
this.isDraggedWithChild = false;
|
|
8113
|
-
/** @hidden
|
|
8138
|
+
/** @hidden
|
|
8139
|
+
* Indicates whether multiple TreeGrid instances are being managed or displayed.
|
|
8140
|
+
*/
|
|
8114
8141
|
this.modifiedRecords = 'modifiedRecords';
|
|
8115
|
-
/** @hidden
|
|
8142
|
+
/** @hidden
|
|
8143
|
+
* Represents the currently selected item in the TreeGrid.
|
|
8144
|
+
*/
|
|
8116
8145
|
this.selectedRecords = 'selectedRecords';
|
|
8117
|
-
/** @hidden
|
|
8146
|
+
/** @hidden
|
|
8147
|
+
* Holds an array of currently selected records in the TreeGrid.
|
|
8148
|
+
*/
|
|
8118
8149
|
this.selectedRows = 'selectedRows';
|
|
8119
|
-
/** @hidden
|
|
8150
|
+
/** @hidden
|
|
8151
|
+
* Indicates whether there is a droppable item in the TreeGrid.
|
|
8152
|
+
*/
|
|
8120
8153
|
this.hasDropItem = true;
|
|
8121
|
-
/** @hidden
|
|
8154
|
+
/** @hidden
|
|
8155
|
+
* Indicates whether the item is being added to the bottom of the TreeGrid.
|
|
8156
|
+
*/
|
|
8122
8157
|
this.isaddtoBottom = false;
|
|
8123
8158
|
Grid.Inject(RowDD$1);
|
|
8124
8159
|
this.parent = parent;
|
|
8125
8160
|
this.addEventListener();
|
|
8126
8161
|
}
|
|
8162
|
+
/**
|
|
8163
|
+
* Retrieves child records for a specified parent ID in the TreeGrid.
|
|
8164
|
+
*
|
|
8165
|
+
* @param {string} id - The unique ID of the parent record for which to retrieve child records.
|
|
8166
|
+
* @returns {ITreeData[]} An array of child records corresponding to the specified parent ID.
|
|
8167
|
+
*/
|
|
8127
8168
|
getChildrecordsByParentID(id) {
|
|
8128
8169
|
let treeGridDataSource;
|
|
8129
8170
|
if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
|
|
@@ -8157,6 +8198,9 @@ class RowDD {
|
|
|
8157
8198
|
*/
|
|
8158
8199
|
reorderRows(fromIndexes, toIndex, position) {
|
|
8159
8200
|
const tObj = this.parent;
|
|
8201
|
+
if (fromIndexes[0] === toIndex || ['above', 'below', 'child'].indexOf(position) === -1) {
|
|
8202
|
+
return;
|
|
8203
|
+
}
|
|
8160
8204
|
const action = 'action';
|
|
8161
8205
|
const dropPosition = 'dropPosition';
|
|
8162
8206
|
const updateRowAndCellElements = 'updateRowAndCellElements';
|
|
@@ -8195,13 +8239,9 @@ class RowDD {
|
|
|
8195
8239
|
}
|
|
8196
8240
|
this.parent.grid.refresh();
|
|
8197
8241
|
if (this.parent.enableImmutableMode && this.dropPosition === 'middleSegment') {
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
}
|
|
8202
|
-
else if (this.parent[`${action}`] === 'indenting') {
|
|
8203
|
-
index = this.parent.treeColumnIndex;
|
|
8204
|
-
}
|
|
8242
|
+
const index = this.parent.allowRowDragAndDrop
|
|
8243
|
+
? this.parent.treeColumnIndex + 1
|
|
8244
|
+
: (this.parent[`${action}`] === 'indenting' ? this.parent.treeColumnIndex : undefined);
|
|
8205
8245
|
const row = this.parent.getRows()[fromIndexes[0]];
|
|
8206
8246
|
const dropData = args.data[0];
|
|
8207
8247
|
const totalRecord = [];
|
|
@@ -8216,13 +8256,9 @@ class RowDD {
|
|
|
8216
8256
|
this.parent[`${updateRowAndCellElements}`](totalRecord, rows, index);
|
|
8217
8257
|
}
|
|
8218
8258
|
if (this.parent.enableImmutableMode && this.parent[`${action}`] === 'outdenting') {
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
}
|
|
8223
|
-
else if (this.parent[`${action}`] === 'outdenting') {
|
|
8224
|
-
index = this.parent.treeColumnIndex;
|
|
8225
|
-
}
|
|
8259
|
+
const index = this.parent.allowRowDragAndDrop
|
|
8260
|
+
? this.parent.treeColumnIndex + 1
|
|
8261
|
+
: (this.parent[`${action}`] === 'outdenting' ? this.parent.treeColumnIndex : undefined);
|
|
8226
8262
|
const record = args.data[0];
|
|
8227
8263
|
const row = this.parent.getRows()[fromIndexes[0]];
|
|
8228
8264
|
const totalRecord = [];
|
|
@@ -8232,10 +8268,14 @@ class RowDD {
|
|
|
8232
8268
|
this.parent[`${updateRowAndCellElements}`](totalRecord, rows, index);
|
|
8233
8269
|
}
|
|
8234
8270
|
}
|
|
8235
|
-
else {
|
|
8236
|
-
return;
|
|
8237
|
-
}
|
|
8238
8271
|
}
|
|
8272
|
+
/**
|
|
8273
|
+
* Performs indent or outdent actions on selected records in the TreeGrid.
|
|
8274
|
+
*
|
|
8275
|
+
* @param {ITreeData} [record] - The record to be indented or outdented. If undefined, the method operates on the currently selected record.
|
|
8276
|
+
* @param {string} [request] - The action to perform, either 'indent' or 'outdent'.
|
|
8277
|
+
* @returns {void}
|
|
8278
|
+
*/
|
|
8239
8279
|
indentOutdentAction(record, request) {
|
|
8240
8280
|
const tObj = this.parent;
|
|
8241
8281
|
const action = 'action';
|
|
@@ -8310,6 +8350,13 @@ class RowDD {
|
|
|
8310
8350
|
}
|
|
8311
8351
|
}
|
|
8312
8352
|
}
|
|
8353
|
+
/**
|
|
8354
|
+
* Triggers a specified event for the TreeGrid, notifying subscribers about the event occurrence.
|
|
8355
|
+
*
|
|
8356
|
+
* @param {string} action - The action to be triggered, either 'indenting' or 'outdenting'.
|
|
8357
|
+
* @param {number} dropIndex - The index at which the row should be dropped.
|
|
8358
|
+
* @returns {void}
|
|
8359
|
+
*/
|
|
8313
8360
|
eventTrigger(action, dropIndex) {
|
|
8314
8361
|
const actionArgs = {
|
|
8315
8362
|
action: action,
|
|
@@ -8338,6 +8385,12 @@ class RowDD {
|
|
|
8338
8385
|
}
|
|
8339
8386
|
});
|
|
8340
8387
|
}
|
|
8388
|
+
/**
|
|
8389
|
+
* Reorders the flat data array of the TreeGrid and updates the index of each record.
|
|
8390
|
+
*
|
|
8391
|
+
* @param {ITreeData[]} currentData - The array of tree data records to reorder.
|
|
8392
|
+
* @returns {ITreeData[]} The updated array of tree data records with indices set.
|
|
8393
|
+
*/
|
|
8341
8394
|
orderToIndex(currentData) {
|
|
8342
8395
|
for (let i = 0; i < currentData.length; i++) {
|
|
8343
8396
|
currentData[parseInt(i.toString(), 10)].index = i;
|
|
@@ -8348,6 +8401,15 @@ class RowDD {
|
|
|
8348
8401
|
}
|
|
8349
8402
|
return currentData;
|
|
8350
8403
|
}
|
|
8404
|
+
/**
|
|
8405
|
+
* Handles the addition of new rows to the TreeGrid.
|
|
8406
|
+
*
|
|
8407
|
+
* @param {Object} e - The event object containing information about the rows being added.
|
|
8408
|
+
* @param {number} e.toIndex - The index at which the new rows should be added in the TreeGrid.
|
|
8409
|
+
* @param {Object[]} e.records - An array of the records to be added to the TreeGrid.
|
|
8410
|
+
*
|
|
8411
|
+
* @returns {void} This function does not return any value.
|
|
8412
|
+
*/
|
|
8351
8413
|
rowsAdded(e) {
|
|
8352
8414
|
let draggedRecord;
|
|
8353
8415
|
const dragRecords = e.records;
|
|
@@ -8452,6 +8514,15 @@ class RowDD {
|
|
|
8452
8514
|
this.dropRows(args);
|
|
8453
8515
|
}
|
|
8454
8516
|
}
|
|
8517
|
+
/**
|
|
8518
|
+
* Handles the removal of specified rows from the TreeGrid.
|
|
8519
|
+
*
|
|
8520
|
+
* @param {Object} e - The event object containing information about the removed rows.
|
|
8521
|
+
* @param {number[]} e.indexes - An array of indexes of the rows that were removed.
|
|
8522
|
+
* @param {Object[]} e.records - An array of the records corresponding to the removed rows.
|
|
8523
|
+
*
|
|
8524
|
+
* @returns {void} This function does not return any value.
|
|
8525
|
+
*/
|
|
8455
8526
|
rowsRemoved(e) {
|
|
8456
8527
|
for (let i = 0; i < e.records.length; i++) {
|
|
8457
8528
|
this.draggedRecord = e.records[parseInt(i.toString(), 10)];
|
|
@@ -8463,35 +8534,36 @@ class RowDD {
|
|
|
8463
8534
|
}
|
|
8464
8535
|
}
|
|
8465
8536
|
}
|
|
8537
|
+
/**
|
|
8538
|
+
* Refreshes the data source of the TreeGrid.
|
|
8539
|
+
*
|
|
8540
|
+
* @returns {void} This function does not return any value.
|
|
8541
|
+
*/
|
|
8466
8542
|
refreshGridDataSource() {
|
|
8467
8543
|
const draggedRecord = this.draggedRecord;
|
|
8468
8544
|
const droppedRecord = this.droppedRecord;
|
|
8469
8545
|
const proxy = this.parent;
|
|
8470
|
-
let
|
|
8471
|
-
let
|
|
8546
|
+
let temporaryDataSource;
|
|
8547
|
+
let indexOfDroppedRecord;
|
|
8472
8548
|
if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
|
|
8473
|
-
|
|
8549
|
+
temporaryDataSource = proxy.dataSource.dataSource.json;
|
|
8474
8550
|
}
|
|
8475
8551
|
else {
|
|
8476
|
-
|
|
8552
|
+
temporaryDataSource = proxy.dataSource;
|
|
8477
8553
|
}
|
|
8478
|
-
if (
|
|
8554
|
+
if (temporaryDataSource && (!isNullOrUndefined(droppedRecord) && !droppedRecord.parentItem)
|
|
8479
8555
|
&& !isNullOrUndefined(droppedRecord.taskData)) {
|
|
8480
|
-
const keys = Object.keys(
|
|
8556
|
+
const keys = Object.keys(temporaryDataSource);
|
|
8481
8557
|
for (let i = 0; i < keys.length; i++) {
|
|
8482
|
-
if (
|
|
8558
|
+
if (temporaryDataSource[parseInt(i.toString(), 10)][this.parent.childMapping] ===
|
|
8483
8559
|
droppedRecord.taskData[this.parent.childMapping]) {
|
|
8484
|
-
|
|
8560
|
+
indexOfDroppedRecord = i;
|
|
8485
8561
|
}
|
|
8486
8562
|
}
|
|
8487
|
-
if (this.
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
}
|
|
8492
|
-
else if (this.dropPosition === 'bottomSegment') {
|
|
8493
|
-
if (!this.parent.idMapping) {
|
|
8494
|
-
tempDataSource.splice(idx + 1, 0, draggedRecord.taskData);
|
|
8563
|
+
if (!this.parent.idMapping) {
|
|
8564
|
+
const positionAdjustment = this.dropPosition === 'topSegment' ? 0 : 1;
|
|
8565
|
+
if (this.dropPosition === 'topSegment' || this.dropPosition === 'bottomSegment') {
|
|
8566
|
+
temporaryDataSource.splice(indexOfDroppedRecord + positionAdjustment, 0, draggedRecord.taskData);
|
|
8495
8567
|
}
|
|
8496
8568
|
}
|
|
8497
8569
|
}
|
|
@@ -8522,6 +8594,12 @@ class RowDD {
|
|
|
8522
8594
|
}
|
|
8523
8595
|
}
|
|
8524
8596
|
}
|
|
8597
|
+
/**
|
|
8598
|
+
* Removes the border from the first row of the TreeGrid.
|
|
8599
|
+
*
|
|
8600
|
+
* @param {HTMLTableRowElement} element - The table row element from which to remove the border.
|
|
8601
|
+
* @returns {void} This function does not return any value.
|
|
8602
|
+
*/
|
|
8525
8603
|
removeFirstrowBorder(element) {
|
|
8526
8604
|
const canremove = this.dropPosition === 'bottomSegment';
|
|
8527
8605
|
if (this.parent.element.getElementsByClassName('e-firstrow-border').length > 0 && element &&
|
|
@@ -8529,25 +8607,40 @@ class RowDD {
|
|
|
8529
8607
|
this.parent.element.getElementsByClassName('e-firstrow-border')[0].remove();
|
|
8530
8608
|
}
|
|
8531
8609
|
}
|
|
8610
|
+
/**
|
|
8611
|
+
* Removes the border from the last row of the TreeGrid.
|
|
8612
|
+
*
|
|
8613
|
+
* @param {HTMLTableRowElement} element - The row element from which to remove the last row border.
|
|
8614
|
+
* @returns {void}
|
|
8615
|
+
*/
|
|
8532
8616
|
removeLastrowBorder(element) {
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
let islastRowIndex;
|
|
8536
|
-
if (this.parent.enableVirtualization) {
|
|
8537
|
-
islastRowIndex = element && !isEmptyRow &&
|
|
8538
|
-
this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1].getAttribute('data-uid') !==
|
|
8539
|
-
element.getAttribute('data-uid');
|
|
8617
|
+
if (!element) {
|
|
8618
|
+
return;
|
|
8540
8619
|
}
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8620
|
+
const isEmptyRow = element.classList.contains('e-emptyrow') ||
|
|
8621
|
+
element.classList.contains('e-columnheader') ||
|
|
8622
|
+
element.classList.contains('e-detailrow');
|
|
8623
|
+
if (isEmptyRow) {
|
|
8624
|
+
return;
|
|
8545
8625
|
}
|
|
8546
|
-
const
|
|
8547
|
-
|
|
8548
|
-
this.parent.
|
|
8626
|
+
const lastRow = this.parent.enableVirtualization ?
|
|
8627
|
+
this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1] :
|
|
8628
|
+
this.parent.getRowByIndex(this.parent.getCurrentViewRecords().length - 1);
|
|
8629
|
+
const isNotLastRow = lastRow.getAttribute('data-uid') !== element.getAttribute('data-uid');
|
|
8630
|
+
const canRemove = isNotLastRow || this.dropPosition === 'topSegment';
|
|
8631
|
+
const lastRowBorderElement = this.parent.element.getElementsByClassName('e-lastrow-border')[0];
|
|
8632
|
+
if (lastRowBorderElement && canRemove) {
|
|
8633
|
+
lastRowBorderElement.remove();
|
|
8549
8634
|
}
|
|
8550
8635
|
}
|
|
8636
|
+
/**
|
|
8637
|
+
* Updates the icons associated with the specified rows in the TreeGrid.
|
|
8638
|
+
*
|
|
8639
|
+
* @param {Element[]} row - The array of row elements to update the icons for.
|
|
8640
|
+
* @param {number} index - The index of the row being updated.
|
|
8641
|
+
* @param {RowDragEventArgs} args - The event arguments associated with the row drag operation.
|
|
8642
|
+
* @returns {string} The drop position ('topSegment', 'middleSegment', 'bottomSegment', or 'Invalid').
|
|
8643
|
+
*/
|
|
8551
8644
|
updateIcon(row, index, args) {
|
|
8552
8645
|
const rowEle = args.target ? closest(args.target, 'tr') : null;
|
|
8553
8646
|
this.dropPosition = undefined;
|
|
@@ -8559,6 +8652,10 @@ class RowDD {
|
|
|
8559
8652
|
|| !parentsUntil(args.target, 'e-gridcontent')) {
|
|
8560
8653
|
this.dropPosition = 'Invalid';
|
|
8561
8654
|
this.addErrorElem();
|
|
8655
|
+
if (isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
|
|
8656
|
+
this.removetopOrBottomBorder();
|
|
8657
|
+
this.removeChildBorder();
|
|
8658
|
+
}
|
|
8562
8659
|
}
|
|
8563
8660
|
}
|
|
8564
8661
|
// To get the corresponding drop position related to mouse position
|
|
@@ -8633,6 +8730,11 @@ class RowDD {
|
|
|
8633
8730
|
}
|
|
8634
8731
|
return this.dropPosition;
|
|
8635
8732
|
}
|
|
8733
|
+
/**
|
|
8734
|
+
* Removes the visual border from all child rows within the TreeGrid.
|
|
8735
|
+
*
|
|
8736
|
+
* @returns {void} No return value.
|
|
8737
|
+
*/
|
|
8636
8738
|
removeChildBorder() {
|
|
8637
8739
|
let borderElem = [];
|
|
8638
8740
|
borderElem = [].slice.call(this.parent.element.querySelectorAll('.e-childborder'));
|
|
@@ -8640,6 +8742,12 @@ class RowDD {
|
|
|
8640
8742
|
this.addRemoveClasses(borderElem, false, 'e-childborder');
|
|
8641
8743
|
}
|
|
8642
8744
|
}
|
|
8745
|
+
/**
|
|
8746
|
+
* Adds a visual border to the first row of the TreeGrid.
|
|
8747
|
+
*
|
|
8748
|
+
* @param {HTMLTableRowElement} targetRow - The target row element to which the border will be added, if it is the first row.
|
|
8749
|
+
* @returns {void} No return value.
|
|
8750
|
+
*/
|
|
8643
8751
|
addFirstrowBorder(targetRow) {
|
|
8644
8752
|
const node = this.parent.element;
|
|
8645
8753
|
const tObj = this.parent;
|
|
@@ -8662,9 +8770,21 @@ class RowDD {
|
|
|
8662
8770
|
}
|
|
8663
8771
|
}
|
|
8664
8772
|
}
|
|
8773
|
+
/**
|
|
8774
|
+
* Adds a visual border to the last row of the TreeGrid.
|
|
8775
|
+
*
|
|
8776
|
+
* @param {HTMLTableRowElement} trElement - The table row element to which the border will be added, if it is the last row.
|
|
8777
|
+
* @returns {void} No return value.
|
|
8778
|
+
*/
|
|
8665
8779
|
addLastRowborder(trElement) {
|
|
8780
|
+
if (!trElement) {
|
|
8781
|
+
return;
|
|
8782
|
+
}
|
|
8666
8783
|
const isEmptyRow = trElement && (trElement.classList.contains('e-emptyrow') ||
|
|
8667
8784
|
trElement.classList.contains('e-columnheader') || trElement.classList.contains('e-detailrow'));
|
|
8785
|
+
if (isEmptyRow) {
|
|
8786
|
+
return;
|
|
8787
|
+
}
|
|
8668
8788
|
if (trElement && !isEmptyRow && this.parent.getRows()[this.parent.getCurrentViewRecords().length - 1].getAttribute('data-uid') ===
|
|
8669
8789
|
trElement.getAttribute('data-uid')) {
|
|
8670
8790
|
const bottomborder = this.parent.createElement('div', { className: 'e-lastrow-border' });
|
|
@@ -8677,40 +8797,55 @@ class RowDD {
|
|
|
8677
8797
|
}
|
|
8678
8798
|
}
|
|
8679
8799
|
}
|
|
8800
|
+
/**
|
|
8801
|
+
* Retrieves the total scroll width of the TreeGrid content area.
|
|
8802
|
+
*
|
|
8803
|
+
* @returns {number} The width of the scrollbar if content overflows, otherwise 0.
|
|
8804
|
+
*/
|
|
8680
8805
|
getScrollWidth() {
|
|
8681
8806
|
const scrollElem = this.parent.getContent().firstElementChild;
|
|
8682
8807
|
return scrollElem.scrollWidth > scrollElem.offsetWidth ? Scroll.getScrollBarWidth() : 0;
|
|
8683
8808
|
}
|
|
8809
|
+
/**
|
|
8810
|
+
* Adds an error element to the dragged row element during a row drag-and-drop operation.
|
|
8811
|
+
*
|
|
8812
|
+
* @returns {void} No return value.
|
|
8813
|
+
*/
|
|
8684
8814
|
addErrorElem() {
|
|
8685
8815
|
const dragelem = document.getElementsByClassName('e-cloneproperties')[0];
|
|
8686
|
-
const
|
|
8816
|
+
const errorelemCount = dragelem.querySelectorAll('.e-errorelem').length;
|
|
8687
8817
|
const sanitize = 'sanitize';
|
|
8688
|
-
if (!
|
|
8689
|
-
const
|
|
8690
|
-
classList(
|
|
8691
|
-
|
|
8818
|
+
if (!errorelemCount && !this.parent.rowDropSettings.targetID) {
|
|
8819
|
+
const errorContainer = document.createElement('div');
|
|
8820
|
+
errorContainer.classList.add('e-errorcontainer', 'e-icons', 'e-errorelem');
|
|
8821
|
+
const rowCell = dragelem.querySelector('.e-rowcell');
|
|
8692
8822
|
const errorVal = dragelem.querySelector('.errorValue');
|
|
8693
|
-
let content =
|
|
8823
|
+
let content = rowCell.innerHTML;
|
|
8694
8824
|
if (errorVal) {
|
|
8695
8825
|
content = this.parent[`${sanitize}`](errorVal.innerHTML);
|
|
8696
8826
|
errorVal.parentNode.removeChild(errorVal);
|
|
8697
8827
|
}
|
|
8698
|
-
|
|
8828
|
+
rowCell.innerHTML = '';
|
|
8699
8829
|
const spanContent = document.createElement('span');
|
|
8700
8830
|
spanContent.className = 'errorValue';
|
|
8701
8831
|
spanContent.style.paddingLeft = '16px';
|
|
8702
8832
|
spanContent.innerHTML = this.parent[`${sanitize}`](content);
|
|
8703
|
-
|
|
8704
|
-
|
|
8833
|
+
rowCell.appendChild(errorContainer);
|
|
8834
|
+
rowCell.appendChild(spanContent);
|
|
8705
8835
|
const dropItemSpan = document.querySelector('.e-dropitemscount');
|
|
8706
8836
|
if (this.hasDropItem && dropItemSpan) {
|
|
8707
|
-
const dropItemLeft = parseInt(dropItemSpan.style.left, 10) +
|
|
8837
|
+
const dropItemLeft = parseInt(dropItemSpan.style.left, 10) + errorContainer.offsetWidth + 16;
|
|
8708
8838
|
const spanLeft = !this.parent.enableRtl ? dropItemLeft : 0;
|
|
8709
8839
|
dropItemSpan.style.left = `${spanLeft}px`;
|
|
8710
8840
|
this.hasDropItem = false;
|
|
8711
8841
|
}
|
|
8712
8842
|
}
|
|
8713
8843
|
}
|
|
8844
|
+
/**
|
|
8845
|
+
* Removes the error element from the DOM and adjusts the position of the drop item count if necessary.
|
|
8846
|
+
*
|
|
8847
|
+
* @returns {void} No return value.
|
|
8848
|
+
*/
|
|
8714
8849
|
removeErrorElem() {
|
|
8715
8850
|
const errorelem = document.querySelector('.e-errorelem');
|
|
8716
8851
|
const errorValue = document.querySelector('.errorValue');
|
|
@@ -8731,6 +8866,12 @@ class RowDD {
|
|
|
8731
8866
|
}
|
|
8732
8867
|
this.hasDropItem = true;
|
|
8733
8868
|
}
|
|
8869
|
+
/**
|
|
8870
|
+
* Applies drop border styles to row elements based on the current drop position ('topSegment' or 'bottomSegment').
|
|
8871
|
+
*
|
|
8872
|
+
* @param {Element} target - The target element where the drop action is taking place.
|
|
8873
|
+
* @returns {void} No return value.
|
|
8874
|
+
*/
|
|
8734
8875
|
topOrBottomBorder(target) {
|
|
8735
8876
|
let rowElement = [];
|
|
8736
8877
|
const element = closest(target, 'tr');
|
|
@@ -8747,6 +8888,11 @@ class RowDD {
|
|
|
8747
8888
|
}
|
|
8748
8889
|
}
|
|
8749
8890
|
}
|
|
8891
|
+
/**
|
|
8892
|
+
* Removes the drop border classes ('e-dropbottom' and 'e-droptop') from the parent element if present.
|
|
8893
|
+
*
|
|
8894
|
+
* @returns {void} No return value.
|
|
8895
|
+
*/
|
|
8750
8896
|
removetopOrBottomBorder() {
|
|
8751
8897
|
let border = [];
|
|
8752
8898
|
border = [].slice.call(this.parent.element.querySelectorAll('.e-dropbottom, .e-droptop'));
|
|
@@ -8755,6 +8901,14 @@ class RowDD {
|
|
|
8755
8901
|
this.addRemoveClasses(border, false, 'e-droptop');
|
|
8756
8902
|
}
|
|
8757
8903
|
}
|
|
8904
|
+
/**
|
|
8905
|
+
* Adds or removes a specified class from a list of HTML elements.
|
|
8906
|
+
*
|
|
8907
|
+
* @param {Element[]} cells - The list of HTML elements to which the class will be added or removed.
|
|
8908
|
+
* @param {boolean} add - A flag indicating whether to add (`true`) or remove (`false`) the class.
|
|
8909
|
+
* @param {string} className - The class name to be added or removed from each element in `cells`.
|
|
8910
|
+
* @returns {void} No return value.
|
|
8911
|
+
*/
|
|
8758
8912
|
addRemoveClasses(cells, add, className) {
|
|
8759
8913
|
for (let i = 0, len = cells.length; i < len; i++) {
|
|
8760
8914
|
if (add) {
|
|
@@ -8765,6 +8919,12 @@ class RowDD {
|
|
|
8765
8919
|
}
|
|
8766
8920
|
}
|
|
8767
8921
|
}
|
|
8922
|
+
/**
|
|
8923
|
+
* Calculates the offset position of the specified HTML element relative to the document.
|
|
8924
|
+
*
|
|
8925
|
+
* @param {Element} element - The HTML element for which the offset position is calculated.
|
|
8926
|
+
* @returns {PositionOffSet} The offset position containing `top` and `left` values.
|
|
8927
|
+
*/
|
|
8768
8928
|
getOffset(element) {
|
|
8769
8929
|
const box = element.getBoundingClientRect();
|
|
8770
8930
|
const body = document.body;
|
|
@@ -8777,35 +8937,38 @@ class RowDD {
|
|
|
8777
8937
|
const left = box.left + scrollLeft - clientLeft;
|
|
8778
8938
|
return { top: Math.round(top), left: Math.round(left) };
|
|
8779
8939
|
}
|
|
8940
|
+
/**
|
|
8941
|
+
* Handles the dragging of rows in the TreeGrid.
|
|
8942
|
+
*
|
|
8943
|
+
* @param {RowDragEventArgs} args - The event arguments for the row drag action.
|
|
8944
|
+
* @returns {void} This function does not return a value.
|
|
8945
|
+
*/
|
|
8780
8946
|
Rowdraging(args) {
|
|
8781
8947
|
const tObj = this.parent;
|
|
8782
8948
|
const cloneElement = this.parent.element.querySelector('.e-cloneproperties');
|
|
8949
|
+
if (!cloneElement) {
|
|
8950
|
+
return;
|
|
8951
|
+
}
|
|
8783
8952
|
cloneElement.style.cursor = '';
|
|
8784
8953
|
const rowEle = args.target ? closest(args.target, 'tr') : null;
|
|
8785
8954
|
const rowIdx = rowEle ? rowEle.rowIndex : -1;
|
|
8786
|
-
|
|
8787
|
-
const droppedRecord = tObj.getCurrentViewRecords()[parseInt(rowIdx.toString(), 10)];
|
|
8788
|
-
this.removeErrorElem();
|
|
8789
|
-
this.canDrop = true;
|
|
8790
|
-
if (!args.data[0]) {
|
|
8791
|
-
dragRecords.push(args.data);
|
|
8792
|
-
}
|
|
8793
|
-
else {
|
|
8794
|
-
dragRecords = args.data;
|
|
8795
|
-
}
|
|
8796
|
-
if (rowIdx !== -1) {
|
|
8797
|
-
this.ensuredropPosition(dragRecords, droppedRecord);
|
|
8798
|
-
}
|
|
8799
|
-
else {
|
|
8955
|
+
if (rowIdx === -1) {
|
|
8800
8956
|
this.canDrop = false;
|
|
8801
8957
|
this.addErrorElem();
|
|
8958
|
+
if (isNullOrUndefined(tObj.rowDropSettings.targetID)) {
|
|
8959
|
+
this.removetopOrBottomBorder();
|
|
8960
|
+
this.removeChildBorder();
|
|
8961
|
+
}
|
|
8962
|
+
return;
|
|
8802
8963
|
}
|
|
8964
|
+
const dragRecords = Array.isArray(args.data) ? args.data : [args.data];
|
|
8965
|
+
const droppedRecord = tObj.getCurrentViewRecords()[parseInt(rowIdx.toString(), 10)];
|
|
8966
|
+
this.removeErrorElem();
|
|
8967
|
+
this.canDrop = true;
|
|
8968
|
+
this.ensuredropPosition(dragRecords, droppedRecord);
|
|
8803
8969
|
if (!tObj.rowDropSettings.targetID && this.canDrop && !isNullOrUndefined(args.rows[0])) {
|
|
8804
8970
|
tObj.rowDragAndDropModule.updateIcon(args.rows, rowIdx, args);
|
|
8805
8971
|
}
|
|
8806
|
-
if (isNullOrUndefined(tObj.rowDropSettings.targetID) && !this.canDrop) {
|
|
8807
|
-
this.removetopOrBottomBorder();
|
|
8808
|
-
}
|
|
8809
8972
|
if (tObj.rowDropSettings.targetID) {
|
|
8810
8973
|
const dropElement = parentsUntil(args.target, 'e-treegrid');
|
|
8811
8974
|
if (dropElement && dropElement.id === this.parent.rowDropSettings.targetID) {
|
|
@@ -8820,17 +8983,26 @@ class RowDD {
|
|
|
8820
8983
|
}
|
|
8821
8984
|
}
|
|
8822
8985
|
}
|
|
8986
|
+
/**
|
|
8987
|
+
* Handles the row drop event for the TreeGrid.
|
|
8988
|
+
*
|
|
8989
|
+
* @param {RowDropEventArgs} args - The event arguments for the row drop action.
|
|
8990
|
+
* @returns {void} This function does not return a value.
|
|
8991
|
+
*/
|
|
8823
8992
|
rowDropped(args) {
|
|
8824
8993
|
const tObj = this.parent;
|
|
8825
8994
|
const parentItem = 'parentItem';
|
|
8826
8995
|
if (!tObj.rowDropSettings.targetID) {
|
|
8827
|
-
if (parentsUntil(args.target, 'e-content')) {
|
|
8996
|
+
if (parentsUntil(args.target, 'e-content') || (this.dropPosition === 'Invalid' || !this.canDrop)) {
|
|
8828
8997
|
if (this.parent.element.querySelector('.e-errorelem')) {
|
|
8829
8998
|
this.dropPosition = 'Invalid';
|
|
8830
8999
|
}
|
|
8831
9000
|
setValue('dropPosition', this.dropPosition, args);
|
|
8832
9001
|
tObj.trigger(rowDrop, args);
|
|
8833
9002
|
if (!args.cancel) {
|
|
9003
|
+
if (!isCountRequired(this.parent) && this.dropPosition === 'Invalid') {
|
|
9004
|
+
return;
|
|
9005
|
+
}
|
|
8834
9006
|
if (!isCountRequired(this.parent)) {
|
|
8835
9007
|
this.dropRows(args);
|
|
8836
9008
|
}
|
|
@@ -8838,9 +9010,7 @@ class RowDD {
|
|
|
8838
9010
|
tObj.flatData = this.orderToIndex(tObj.flatData);
|
|
8839
9011
|
}
|
|
8840
9012
|
tObj.grid.refresh();
|
|
8841
|
-
|
|
8842
|
-
tObj.getHeaderContent().querySelector('.e-firstrow-border').remove();
|
|
8843
|
-
}
|
|
9013
|
+
this.removeRowBorders();
|
|
8844
9014
|
}
|
|
8845
9015
|
}
|
|
8846
9016
|
}
|
|
@@ -8859,12 +9029,7 @@ class RowDD {
|
|
|
8859
9029
|
}
|
|
8860
9030
|
this.removetopOrBottomBorder();
|
|
8861
9031
|
this.removeChildBorder();
|
|
8862
|
-
|
|
8863
|
-
this.parent.element.getElementsByClassName('e-firstrow-border')[0].remove();
|
|
8864
|
-
}
|
|
8865
|
-
else if (!isNullOrUndefined(this.parent.element.getElementsByClassName('e-lastrow-border')[0])) {
|
|
8866
|
-
this.parent.element.getElementsByClassName('e-lastrow-border')[0].remove();
|
|
8867
|
-
}
|
|
9032
|
+
this.removeRowBorders();
|
|
8868
9033
|
if (this.parent.enableImmutableMode && !this.parent.allowPaging && !isNullOrUndefined(args.data[0][`${parentItem}`])) {
|
|
8869
9034
|
let index = this.parent.treeColumnIndex;
|
|
8870
9035
|
index = index + 1;
|
|
@@ -8906,6 +9071,25 @@ class RowDD {
|
|
|
8906
9071
|
}
|
|
8907
9072
|
}
|
|
8908
9073
|
}
|
|
9074
|
+
/**
|
|
9075
|
+
* Removes the border elements for the first and last rows of the TreeGrid.
|
|
9076
|
+
*
|
|
9077
|
+
* @returns {void} This function does not return a value.
|
|
9078
|
+
*/
|
|
9079
|
+
removeRowBorders() {
|
|
9080
|
+
['e-firstrow-border', 'e-lastrow-border'].forEach((className) => {
|
|
9081
|
+
const element = this.parent.element.getElementsByClassName(className)[0];
|
|
9082
|
+
if (element) {
|
|
9083
|
+
element.remove();
|
|
9084
|
+
}
|
|
9085
|
+
});
|
|
9086
|
+
}
|
|
9087
|
+
/**
|
|
9088
|
+
* Handles the drag-and-drop operation between TreeGrids, updating the source and target grids.
|
|
9089
|
+
*
|
|
9090
|
+
* @param {RowDropEventArgs} args - The arguments related to the row drop event, including target information and data being dropped.
|
|
9091
|
+
* @returns {void} - This function does not return any value.
|
|
9092
|
+
*/
|
|
8909
9093
|
dragDropGrid(args) {
|
|
8910
9094
|
const tObj = this.parent;
|
|
8911
9095
|
const targetRow = closest(args.target, 'tr');
|
|
@@ -8966,9 +9150,22 @@ class RowDD {
|
|
|
8966
9150
|
srcControl.grid.refresh();
|
|
8967
9151
|
}
|
|
8968
9152
|
}
|
|
9153
|
+
/**
|
|
9154
|
+
* Retrieves the index of the target row based on its 'data-rowindex' attribute.
|
|
9155
|
+
*
|
|
9156
|
+
* @param {Element} targetRow - The target row element from which to retrieve the index.
|
|
9157
|
+
* @returns {number} - The index of the target row, or 0 if the targetRow is null or undefined.
|
|
9158
|
+
*/
|
|
8969
9159
|
getTargetIdx(targetRow) {
|
|
8970
9160
|
return targetRow ? parseInt(targetRow.getAttribute('data-rowindex'), 10) : 0;
|
|
8971
9161
|
}
|
|
9162
|
+
/**
|
|
9163
|
+
* Retrieves the parent data of a given record during a row drag-and-drop operation.
|
|
9164
|
+
*
|
|
9165
|
+
* @param {ITreeData} record - The record for which to retrieve the parent data.
|
|
9166
|
+
* @param {Object[]} [data] - Optional data array containing additional information related to the drop operation.
|
|
9167
|
+
* @returns {void} - This function does not return any value.
|
|
9168
|
+
*/
|
|
8972
9169
|
getParentData(record, data) {
|
|
8973
9170
|
const parentItem = record.parentItem;
|
|
8974
9171
|
let selectedItemIndex = -1;
|
|
@@ -8996,6 +9193,13 @@ class RowDD {
|
|
|
8996
9193
|
}
|
|
8997
9194
|
}
|
|
8998
9195
|
}
|
|
9196
|
+
/**
|
|
9197
|
+
* Handles the row drop operation for the tree grid.
|
|
9198
|
+
*
|
|
9199
|
+
* @param {RowDropEventArgs} args - The event arguments containing details about the drop operation, including the target index and data.
|
|
9200
|
+
* @param {boolean} [isByMethod=false] - Optional flag indicating if the drop operation is triggered by a method.
|
|
9201
|
+
* @returns {void} - This function does not return any value.
|
|
9202
|
+
*/
|
|
8999
9203
|
dropRows(args, isByMethod) {
|
|
9000
9204
|
if (this.dropPosition !== 'Invalid' && !isRemoteData(this.parent)) {
|
|
9001
9205
|
const tObj = this.parent;
|
|
@@ -9044,91 +9248,107 @@ class RowDD {
|
|
|
9044
9248
|
for (let i = 0; i < dragLength; i++) {
|
|
9045
9249
|
draggedRecord = dragRecords[parseInt(i.toString(), 10)];
|
|
9046
9250
|
this.draggedRecord = draggedRecord;
|
|
9047
|
-
if (
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
let correctIndex = this.getTargetIdx(args.target.offsetParent.parentElement);
|
|
9053
|
-
if (isNaN(correctIndex)) {
|
|
9054
|
-
correctIndex = this.getTargetIdx(args.target.parentElement);
|
|
9251
|
+
if (!this.draggedRecord.hasChildRecords) {
|
|
9252
|
+
for (const dragRecord of dragRecords) {
|
|
9253
|
+
if (!isNullOrUndefined(dragRecord.childRecords) &&
|
|
9254
|
+
dragRecord.childRecords.indexOf(this.draggedRecord) !== -1) {
|
|
9255
|
+
this.draggedRecord = undefined;
|
|
9055
9256
|
}
|
|
9056
|
-
args.dropIndex = correctIndex;
|
|
9057
|
-
droppedRecord = this.droppedRecord = this.parent.getCurrentViewRecords()[args.dropIndex];
|
|
9058
9257
|
}
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
if (
|
|
9063
|
-
|
|
9258
|
+
}
|
|
9259
|
+
if (!isNullOrUndefined(this.draggedRecord)) {
|
|
9260
|
+
if (this.dropPosition !== 'Invalid' && !isNullOrUndefined(this.droppedRecord)) {
|
|
9261
|
+
if (!tObj.rowDropSettings.targetID || isByMethod) {
|
|
9262
|
+
this.deleteDragRow();
|
|
9064
9263
|
}
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
if (!droppedRecord.hasChildRecords) {
|
|
9070
|
-
if (this.parent.parentIdMapping) {
|
|
9071
|
-
this.treeData.splice(recordIndex1 + 1, 0, this.draggedRecord.taskData);
|
|
9264
|
+
if (this.draggedRecord === this.droppedRecord) {
|
|
9265
|
+
let correctIndex = this.getTargetIdx(args.target.offsetParent.parentElement);
|
|
9266
|
+
if (isNaN(correctIndex)) {
|
|
9267
|
+
correctIndex = this.getTargetIdx(args.target.parentElement);
|
|
9072
9268
|
}
|
|
9073
|
-
|
|
9269
|
+
args.dropIndex = correctIndex;
|
|
9270
|
+
droppedRecord = this.droppedRecord = this.parent.getCurrentViewRecords()[args.dropIndex];
|
|
9074
9271
|
}
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9272
|
+
if (droppedRecord.parentItem || this.dropPosition === 'middleSegment') {
|
|
9273
|
+
const parentRecords = tObj.parentData;
|
|
9274
|
+
const newParentIndex = parentRecords.indexOf(this.draggedRecord);
|
|
9275
|
+
if (newParentIndex !== -1) {
|
|
9276
|
+
parentRecords.splice(newParentIndex, 1);
|
|
9079
9277
|
}
|
|
9080
|
-
this.treeGridData.splice(recordIndex1 + count + 1, 0, this.draggedRecord);
|
|
9081
9278
|
}
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9279
|
+
const recordIndex1 = this.treeGridData.indexOf(droppedRecord);
|
|
9280
|
+
this.dropAtTop(recordIndex1);
|
|
9281
|
+
if (this.dropPosition === 'bottomSegment') {
|
|
9282
|
+
if (!droppedRecord.hasChildRecords) {
|
|
9283
|
+
if (this.parent.parentIdMapping) {
|
|
9284
|
+
this.treeData.splice(recordIndex1 + 1, 0, this.draggedRecord.taskData);
|
|
9285
|
+
}
|
|
9286
|
+
this.treeGridData.splice(recordIndex1 + 1, 0, this.draggedRecord);
|
|
9088
9287
|
}
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
draggedRecord
|
|
9288
|
+
else {
|
|
9289
|
+
count = this.getChildCount(droppedRecord, 0);
|
|
9290
|
+
if (this.parent.parentIdMapping) {
|
|
9291
|
+
this.treeData.splice(recordIndex1 + count + 1, 0, this.draggedRecord.taskData);
|
|
9292
|
+
}
|
|
9293
|
+
this.treeGridData.splice(recordIndex1 + count + 1, 0, this.draggedRecord);
|
|
9294
|
+
}
|
|
9295
|
+
if (isNullOrUndefined(droppedRecord.parentItem)) {
|
|
9296
|
+
delete draggedRecord.parentItem;
|
|
9297
|
+
delete draggedRecord.parentUniqueID;
|
|
9298
|
+
draggedRecord.level = 0;
|
|
9299
|
+
if (this.parent.parentIdMapping) {
|
|
9300
|
+
draggedRecord[this.parent.parentIdMapping] = null;
|
|
9301
|
+
}
|
|
9302
|
+
}
|
|
9303
|
+
if (droppedRecord.parentItem) {
|
|
9304
|
+
const rec = this.getChildrecordsByParentID(droppedRecord.parentUniqueID);
|
|
9305
|
+
const childRecords = rec[0].childRecords;
|
|
9306
|
+
const droppedRecordIndex = childRecords.indexOf(droppedRecord) + 1;
|
|
9307
|
+
childRecords.splice(droppedRecordIndex, 0, draggedRecord);
|
|
9100
9308
|
draggedRecord.parentItem = droppedRecord.parentItem;
|
|
9309
|
+
draggedRecord.parentUniqueID = droppedRecord.parentUniqueID;
|
|
9101
9310
|
draggedRecord.level = droppedRecord.level;
|
|
9311
|
+
if (this.parent.parentIdMapping) {
|
|
9312
|
+
draggedRecord[this.parent.parentIdMapping] = droppedRecord[this.parent.parentIdMapping];
|
|
9313
|
+
draggedRecord.parentItem = droppedRecord.parentItem;
|
|
9314
|
+
draggedRecord.level = droppedRecord.level;
|
|
9315
|
+
}
|
|
9316
|
+
}
|
|
9317
|
+
if (draggedRecord.hasChildRecords) {
|
|
9318
|
+
const level = 1;
|
|
9319
|
+
this.updateChildRecordLevel(draggedRecord, level);
|
|
9320
|
+
this.updateChildRecord(draggedRecord, recordIndex1 + count + 1);
|
|
9102
9321
|
}
|
|
9103
9322
|
}
|
|
9104
|
-
|
|
9105
|
-
const level = 1;
|
|
9106
|
-
this.updateChildRecordLevel(draggedRecord, level);
|
|
9107
|
-
this.updateChildRecord(draggedRecord, recordIndex1 + count + 1);
|
|
9108
|
-
}
|
|
9323
|
+
this.dropMiddle(recordIndex1);
|
|
9109
9324
|
}
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9325
|
+
if (isNullOrUndefined(draggedRecord.parentItem)) {
|
|
9326
|
+
const parentRecords = tObj.parentData;
|
|
9327
|
+
const newParentIndex = parentRecords.indexOf(this.droppedRecord);
|
|
9328
|
+
let nonRepeat = 0;
|
|
9329
|
+
parentRecords.filter((e) => {
|
|
9330
|
+
if (draggedRecord.uniqueID === e.uniqueID) {
|
|
9331
|
+
nonRepeat++;
|
|
9332
|
+
}
|
|
9333
|
+
});
|
|
9334
|
+
if (this.dropPosition === 'bottomSegment' && nonRepeat === 0) {
|
|
9335
|
+
parentRecords.splice(newParentIndex + 1, 0, draggedRecord);
|
|
9336
|
+
}
|
|
9337
|
+
else if (this.dropPosition === 'topSegment' && nonRepeat === 0) {
|
|
9338
|
+
parentRecords.splice(newParentIndex, 0, draggedRecord);
|
|
9119
9339
|
}
|
|
9120
|
-
});
|
|
9121
|
-
if (this.dropPosition === 'bottomSegment' && nonRepeat === 0) {
|
|
9122
|
-
parentRecords.splice(newParentIndex + 1, 0, draggedRecord);
|
|
9123
|
-
}
|
|
9124
|
-
else if (this.dropPosition === 'topSegment' && nonRepeat === 0) {
|
|
9125
|
-
parentRecords.splice(newParentIndex, 0, draggedRecord);
|
|
9126
9340
|
}
|
|
9341
|
+
tObj.rowDragAndDropModule.refreshGridDataSource();
|
|
9127
9342
|
}
|
|
9128
|
-
tObj.rowDragAndDropModule.refreshGridDataSource();
|
|
9129
9343
|
}
|
|
9130
9344
|
}
|
|
9131
9345
|
}
|
|
9346
|
+
/**
|
|
9347
|
+
* Handles the logic for inserting a dragged record into the middle of a parent record's child records.
|
|
9348
|
+
*
|
|
9349
|
+
* @param {number} recordIndex - The index at which to insert the dragged record relative to the parent record's child records.
|
|
9350
|
+
* @returns {void} - This function does not return any value.
|
|
9351
|
+
*/
|
|
9132
9352
|
dropMiddle(recordIndex) {
|
|
9133
9353
|
const tObj = this.parent;
|
|
9134
9354
|
const childRecords = findChildrenRecords(this.droppedRecord);
|
|
@@ -9149,15 +9369,23 @@ class RowDD {
|
|
|
9149
9369
|
}
|
|
9150
9370
|
}
|
|
9151
9371
|
}
|
|
9372
|
+
/**
|
|
9373
|
+
* Handles the logic for inserting a dragged record at the top of a parent record's child records.
|
|
9374
|
+
*
|
|
9375
|
+
* @param {number} recordIndex1 - The index at which to insert the dragged record in the tree grid data.
|
|
9376
|
+
* @returns {void} - This function does not return any value.
|
|
9377
|
+
*/
|
|
9152
9378
|
dropAtTop(recordIndex1) {
|
|
9153
9379
|
const tObj = this.parent;
|
|
9154
9380
|
if (this.dropPosition === 'topSegment') {
|
|
9155
9381
|
if (tObj.parentIdMapping) {
|
|
9156
9382
|
this.treeData.splice(recordIndex1, 0, this.draggedRecord.taskData);
|
|
9157
9383
|
}
|
|
9158
|
-
|
|
9159
|
-
this.draggedRecord.
|
|
9160
|
-
this.draggedRecord.
|
|
9384
|
+
const targetRecord = this.treeGridData[parseInt(recordIndex1.toString(), 10)];
|
|
9385
|
+
this.draggedRecord.parentItem = targetRecord.parentItem;
|
|
9386
|
+
this.draggedRecord.parentUniqueID = targetRecord.parentUniqueID;
|
|
9387
|
+
this.draggedRecord.level = targetRecord.level;
|
|
9388
|
+
// Insert dragged record into the grid data
|
|
9161
9389
|
this.treeGridData.splice(parseInt(recordIndex1.toString(), 10), 0, this.draggedRecord);
|
|
9162
9390
|
if (this.draggedRecord.hasChildRecords) {
|
|
9163
9391
|
const level = 1;
|
|
@@ -9168,10 +9396,16 @@ class RowDD {
|
|
|
9168
9396
|
const rec = this.getChildrecordsByParentID(this.droppedRecord.parentUniqueID);
|
|
9169
9397
|
const childRecords = rec[0].childRecords;
|
|
9170
9398
|
const droppedRecordIndex = childRecords.indexOf(this.droppedRecord);
|
|
9399
|
+
// Insert the dragged record into the child records at the appropriate position
|
|
9171
9400
|
childRecords.splice(droppedRecordIndex, 0, this.draggedRecord);
|
|
9172
9401
|
}
|
|
9173
9402
|
}
|
|
9174
9403
|
}
|
|
9404
|
+
/**
|
|
9405
|
+
* Updates the level and hierarchy of the dragged record based on the drop position.
|
|
9406
|
+
*
|
|
9407
|
+
* @returns {void} - This function does not return any value.
|
|
9408
|
+
*/
|
|
9175
9409
|
recordLevel() {
|
|
9176
9410
|
const tObj = this.parent;
|
|
9177
9411
|
const draggedRecord = this.draggedRecord;
|
|
@@ -9193,6 +9427,7 @@ class RowDD {
|
|
|
9193
9427
|
draggedRecord.parentItem = parentItem;
|
|
9194
9428
|
draggedRecord.parentUniqueID = droppedRecord.uniqueID;
|
|
9195
9429
|
droppedRecord.childRecords.splice(droppedRecord.childRecords.length, 0, draggedRecord);
|
|
9430
|
+
setValue('uniqueIDCollection.' + draggedRecord.uniqueID, draggedRecord, tObj);
|
|
9196
9431
|
const isSelfReference = 'isSelfReference';
|
|
9197
9432
|
if (tObj[`${isSelfReference}`]) {
|
|
9198
9433
|
droppedRecord[tObj.childMapping] = [];
|
|
@@ -9212,6 +9447,11 @@ class RowDD {
|
|
|
9212
9447
|
droppedRecord.expanded = true;
|
|
9213
9448
|
}
|
|
9214
9449
|
}
|
|
9450
|
+
/**
|
|
9451
|
+
* Deletes the currently dragged row from the TreeGrid.
|
|
9452
|
+
*
|
|
9453
|
+
* @returns {void} - This function does not return any value.
|
|
9454
|
+
*/
|
|
9215
9455
|
deleteDragRow() {
|
|
9216
9456
|
if (this.parent.dataSource instanceof DataManager && isOffline(this.parent)) {
|
|
9217
9457
|
this.treeGridData = this.parent.grid.dataSource.dataSource.json;
|
|
@@ -9227,6 +9467,13 @@ class RowDD {
|
|
|
9227
9467
|
}
|
|
9228
9468
|
this.removeRecords(deletedRow);
|
|
9229
9469
|
}
|
|
9470
|
+
/**
|
|
9471
|
+
* Updates the child records of a specified parent record in the TreeGrid.
|
|
9472
|
+
*
|
|
9473
|
+
* @param {ITreeData} record - The parent record whose child records will be updated.
|
|
9474
|
+
* @param {number} count - The initial count to keep track of record positioning.
|
|
9475
|
+
* @returns {number} - The updated count after processing all child records.
|
|
9476
|
+
*/
|
|
9230
9477
|
updateChildRecord(record, count) {
|
|
9231
9478
|
let currentRecord;
|
|
9232
9479
|
const tObj = this.parent;
|
|
@@ -9254,6 +9501,13 @@ class RowDD {
|
|
|
9254
9501
|
}
|
|
9255
9502
|
return count;
|
|
9256
9503
|
}
|
|
9504
|
+
/**
|
|
9505
|
+
* Updates the level of child records for a specified parent record in the TreeGrid.
|
|
9506
|
+
*
|
|
9507
|
+
* @param {ITreeData} record - The parent record whose child records' levels will be updated.
|
|
9508
|
+
* @param {number} level - The current level of the parent record.
|
|
9509
|
+
* @returns {number} - The updated level after processing all child records.
|
|
9510
|
+
*/
|
|
9257
9511
|
updateChildRecordLevel(record, level) {
|
|
9258
9512
|
let length = 0;
|
|
9259
9513
|
let currentRecord;
|
|
@@ -9284,6 +9538,12 @@ class RowDD {
|
|
|
9284
9538
|
}
|
|
9285
9539
|
return level;
|
|
9286
9540
|
}
|
|
9541
|
+
/**
|
|
9542
|
+
* Removes specified records from the TreeGrid data source.
|
|
9543
|
+
*
|
|
9544
|
+
* @param {ITreeData} record - The record to be removed, including any child records if applicable.
|
|
9545
|
+
* @returns {void} - This method does not return a value.
|
|
9546
|
+
*/
|
|
9287
9547
|
removeRecords(record) {
|
|
9288
9548
|
const tObj = this.parent;
|
|
9289
9549
|
let dataSource;
|
|
@@ -9366,6 +9626,12 @@ class RowDD {
|
|
|
9366
9626
|
}
|
|
9367
9627
|
}
|
|
9368
9628
|
}
|
|
9629
|
+
/**
|
|
9630
|
+
* Updates the records in the TreeGrid data source that have been modified.
|
|
9631
|
+
*
|
|
9632
|
+
* @param {ITreeData} record - The record to update, along with its parent records if applicable.
|
|
9633
|
+
* @returns {void} - This method does not return a value.
|
|
9634
|
+
*/
|
|
9369
9635
|
updateModifiedRecords(record) {
|
|
9370
9636
|
const parentData = getParentData(this.parent, record.parentUniqueID);
|
|
9371
9637
|
if (!isNullOrUndefined(parentData)) {
|
|
@@ -9373,6 +9639,12 @@ class RowDD {
|
|
|
9373
9639
|
this.updateModifiedRecords(parentData);
|
|
9374
9640
|
}
|
|
9375
9641
|
}
|
|
9642
|
+
/**
|
|
9643
|
+
* Recursively removes child records from the specified record and updates the data source.
|
|
9644
|
+
*
|
|
9645
|
+
* @param {ITreeData} record - The parent record whose child records are to be removed.
|
|
9646
|
+
* @returns {void} - This method does not return a value.
|
|
9647
|
+
*/
|
|
9376
9648
|
removeChildItem(record) {
|
|
9377
9649
|
let currentRecord;
|
|
9378
9650
|
let idx;
|
|
@@ -9419,6 +9691,13 @@ class RowDD {
|
|
|
9419
9691
|
}
|
|
9420
9692
|
}
|
|
9421
9693
|
}
|
|
9694
|
+
/**
|
|
9695
|
+
* Retrieves the count of child records associated with the specified parent record.
|
|
9696
|
+
*
|
|
9697
|
+
* @param {ITreeData} record - The parent record for which child count is to be calculated.
|
|
9698
|
+
* @param {number} count - The initial count to start with, usually passed as 0.
|
|
9699
|
+
* @returns {number} - The total count of child records.
|
|
9700
|
+
*/
|
|
9422
9701
|
getChildCount(record, count) {
|
|
9423
9702
|
let currentRecord;
|
|
9424
9703
|
if (!record.hasChildRecords) {
|
|
@@ -9433,6 +9712,14 @@ class RowDD {
|
|
|
9433
9712
|
}
|
|
9434
9713
|
return count;
|
|
9435
9714
|
}
|
|
9715
|
+
/**
|
|
9716
|
+
* Ensures the validity of the drop position for the dragged records by verifying the hierarchy and position constraints.
|
|
9717
|
+
* If the current record is found in the dragged records' children, sets the drop position to 'Invalid'.
|
|
9718
|
+
*
|
|
9719
|
+
* @param {ITreeData[]} draggedRecords - The array of dragged records being verified.
|
|
9720
|
+
* @param {ITreeData} currentRecord - The current record to check against dragged records.
|
|
9721
|
+
* @returns {void} - This function does not return a value.
|
|
9722
|
+
*/
|
|
9436
9723
|
ensuredropPosition(draggedRecords, currentRecord) {
|
|
9437
9724
|
draggedRecords.filter((e) => {
|
|
9438
9725
|
if (e.hasChildRecords && !isNullOrUndefined(e.childRecords)) {
|
|
@@ -9444,11 +9731,28 @@ class RowDD {
|
|
|
9444
9731
|
this.dropPosition = 'Invalid';
|
|
9445
9732
|
this.addErrorElem();
|
|
9446
9733
|
this.canDrop = false;
|
|
9734
|
+
if (isNullOrUndefined(this.parent.rowDropSettings.targetID)) {
|
|
9735
|
+
this.removetopOrBottomBorder();
|
|
9736
|
+
this.removeChildBorder();
|
|
9737
|
+
}
|
|
9447
9738
|
return;
|
|
9448
9739
|
}
|
|
9449
9740
|
}
|
|
9450
9741
|
});
|
|
9451
9742
|
}
|
|
9743
|
+
isDuplicateData(currentData) {
|
|
9744
|
+
const primaryKeys = this.parent.getPrimaryKeyFieldNames();
|
|
9745
|
+
if (primaryKeys.length === 0) {
|
|
9746
|
+
return false;
|
|
9747
|
+
}
|
|
9748
|
+
return this.parent.flatData.some((data) =>
|
|
9749
|
+
// eslint-disable-next-line
|
|
9750
|
+
primaryKeys.every((key) => data[key] === currentData[key]));
|
|
9751
|
+
}
|
|
9752
|
+
/**
|
|
9753
|
+
* Cleans up resources, event listeners, and DOM elements when the TreeGrid component is destroyed.
|
|
9754
|
+
* @returns {void}
|
|
9755
|
+
*/
|
|
9452
9756
|
destroy() {
|
|
9453
9757
|
this.removeEventListener();
|
|
9454
9758
|
}
|
|
@@ -11032,7 +11336,9 @@ class ContextMenu {
|
|
|
11032
11336
|
if (((indent || outdent) || tObj.grid.isEdit) && isNullOrUndefined(selectedrow)) {
|
|
11033
11337
|
for (const items of args.items) {
|
|
11034
11338
|
if (items.text === 'Outdent' || items.text === 'Indent') {
|
|
11035
|
-
tObj.grid.contextMenuModule['hiddenItems'].
|
|
11339
|
+
if (!tObj.grid.contextMenuModule['hiddenItems'].includes(items.text)) {
|
|
11340
|
+
tObj.grid.contextMenuModule['hiddenItems'].push(items.text);
|
|
11341
|
+
}
|
|
11036
11342
|
}
|
|
11037
11343
|
}
|
|
11038
11344
|
tObj.grid.contextMenuModule.contextMenu.hideItems(tObj.grid.contextMenuModule['hiddenItems']);
|
|
@@ -11221,69 +11527,71 @@ class BatchEdit {
|
|
|
11221
11527
|
this.batchAddRowRecord = extendArray(this.batchAddRowRecord);
|
|
11222
11528
|
this.batchAddRowRecord.push(this.batchRecords[this.addRowIndex]);
|
|
11223
11529
|
added = this.parent.grid.getRowsObject()[parseInt(rowObjectIndex.toString(), 10)].changes;
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11530
|
+
if (!isNullOrUndefined(added)) {
|
|
11531
|
+
added.uniqueID = getUid(this.parent.element.id + '_data_');
|
|
11532
|
+
setValue('uniqueIDCollection.' + added.uniqueID, added, this.parent);
|
|
11533
|
+
if (!Object.prototype.hasOwnProperty.call(added, 'level')) {
|
|
11534
|
+
this.batchIndex = this.selectedIndex === -1 ? 0 : this.batchIndex;
|
|
11535
|
+
if (this.parent.editSettings.newRowPosition === 'Child') {
|
|
11536
|
+
added.primaryParent = parentRecord;
|
|
11537
|
+
if (this.selectedIndex > -1) {
|
|
11538
|
+
added.parentItem = extend$1({}, this.batchRecords[this.addRowIndex]);
|
|
11539
|
+
added.parentUniqueID = added.parentItem.uniqueID;
|
|
11540
|
+
delete added.parentItem.childRecords;
|
|
11541
|
+
delete added.parentItem[this.parent.childMapping];
|
|
11542
|
+
added.level = added.parentItem.level + 1;
|
|
11543
|
+
added.index = this.batchIndex;
|
|
11544
|
+
const childRecordCount = findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
|
|
11545
|
+
let record = findChildrenRecords(this.batchRecords[this.addRowIndex])[childRecordCount - 1];
|
|
11546
|
+
record = isNullOrUndefined(record) ? this.batchRecords[this.addRowIndex] : record;
|
|
11547
|
+
currentDataIndex = data.map((e) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
|
|
11548
|
+
if (this.isSelfReference) {
|
|
11549
|
+
added[this.parent.parentIdMapping] = idMapping;
|
|
11550
|
+
}
|
|
11551
|
+
updateParentRow(primaryKey, added.parentItem, 'add', this.parent, this.isSelfReference, added);
|
|
11243
11552
|
}
|
|
11244
|
-
updateParentRow(primaryKey, added.parentItem, 'add', this.parent, this.isSelfReference, added);
|
|
11245
11553
|
}
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11554
|
+
else if ((this.parent.editSettings.newRowPosition === 'Above' || this.parent.editSettings.newRowPosition === 'Below')
|
|
11555
|
+
&& !isNullOrUndefined(this.batchRecords[this.addRowIndex])) {
|
|
11556
|
+
added.level = this.batchRecords[parseInt(this.addRowIndex.toString(), 10)][`${level}`];
|
|
11557
|
+
if (added.level && this.selectedIndex > -1) {
|
|
11558
|
+
added.parentItem = parentRecord;
|
|
11559
|
+
added.parentUniqueID = parentUniqueID;
|
|
11560
|
+
delete added.parentItem.childRecords;
|
|
11561
|
+
delete added.parentItem[this.parent.childMapping];
|
|
11562
|
+
}
|
|
11563
|
+
added.index = this.parent.editSettings.newRowPosition === 'Below' ? this.batchIndex : this.batchIndex - 1;
|
|
11564
|
+
if (this.parent.editSettings.newRowPosition === 'Below' && this.selectedIndex > -1) {
|
|
11565
|
+
const childRecordCount = findChildrenRecords(this.batchRecords[this.addRowIndex]).length;
|
|
11566
|
+
let record = findChildrenRecords(this.batchRecords[this.addRowIndex])[childRecordCount - 1];
|
|
11567
|
+
record = isNullOrUndefined(record) ? this.batchRecords[this.addRowIndex] : record;
|
|
11568
|
+
currentDataIndex = data.map((e) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
|
|
11569
|
+
}
|
|
11570
|
+
if (this.parent.editSettings.newRowPosition === 'Above' && this.selectedIndex > -1) {
|
|
11571
|
+
const record = this.batchRecords[this.addRowIndex];
|
|
11572
|
+
currentDataIndex = data.map((e) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
|
|
11573
|
+
}
|
|
11574
|
+
if (this.isSelfReference) {
|
|
11575
|
+
added[this.parent.parentIdMapping] = parentIdMapping;
|
|
11576
|
+
}
|
|
11255
11577
|
}
|
|
11256
|
-
added.index =
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11578
|
+
added.index = added.index === -1 ? 0 : added.index;
|
|
11579
|
+
added.hasChildRecords = false;
|
|
11580
|
+
added.childRecords = [];
|
|
11581
|
+
this.batchRecords.splice(added.index, 0, added);
|
|
11582
|
+
this.currentViewRecords.splice(added.index, 0, added);
|
|
11583
|
+
if (currentDataIndex) {
|
|
11584
|
+
indexvalue = currentDataIndex;
|
|
11262
11585
|
}
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
currentDataIndex = data.map((e) => { return e[`${primaryKey}`]; }).indexOf(record[`${primaryKey}`]);
|
|
11586
|
+
else {
|
|
11587
|
+
indexvalue = added.index;
|
|
11266
11588
|
}
|
|
11267
|
-
if (this.
|
|
11268
|
-
added
|
|
11589
|
+
if (this.parent.editSettings.newRowPosition !== 'Above') {
|
|
11590
|
+
indexvalue = added.index === 0 ? indexvalue : indexvalue + 1;
|
|
11269
11591
|
}
|
|
11592
|
+
data.splice(indexvalue, 0, added);
|
|
11593
|
+
this.batchAddedRecords.push(added);
|
|
11270
11594
|
}
|
|
11271
|
-
added.index = added.index === -1 ? 0 : added.index;
|
|
11272
|
-
added.hasChildRecords = false;
|
|
11273
|
-
added.childRecords = [];
|
|
11274
|
-
this.batchRecords.splice(added.index, 0, added);
|
|
11275
|
-
this.currentViewRecords.splice(added.index, 0, added);
|
|
11276
|
-
if (currentDataIndex) {
|
|
11277
|
-
indexvalue = currentDataIndex;
|
|
11278
|
-
}
|
|
11279
|
-
else {
|
|
11280
|
-
indexvalue = added.index;
|
|
11281
|
-
}
|
|
11282
|
-
if (this.parent.editSettings.newRowPosition !== 'Above') {
|
|
11283
|
-
indexvalue = added.index === 0 ? indexvalue : indexvalue + 1;
|
|
11284
|
-
}
|
|
11285
|
-
data.splice(indexvalue, 0, added);
|
|
11286
|
-
this.batchAddedRecords.push(added);
|
|
11287
11595
|
}
|
|
11288
11596
|
this.parent.grid.getRowsObject()[parseInt(rowObjectIndex.toString(), 10)].data = added;
|
|
11289
11597
|
this.newBatchRowAdded = false;
|
|
@@ -13325,9 +13633,15 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
|
|
|
13325
13633
|
firsttdinx = +attr; // this.parent.getContent().querySelector('.e-content tr').getAttribute('data-rowindex');
|
|
13326
13634
|
}
|
|
13327
13635
|
if (firsttdinx === 0) {
|
|
13328
|
-
this.
|
|
13329
|
-
|
|
13330
|
-
this.parent.
|
|
13636
|
+
if (this.endIndex - this.startIndex < this.parent.pageSettings.pageSize) {
|
|
13637
|
+
this.translateY = !isNullOrUndefined(this.endIndex) ?
|
|
13638
|
+
(this.endIndex - this.parent.pageSettings.pageSize) * (this.parent.rowHeight ?
|
|
13639
|
+
this.parent.rowHeight : this.parent.getRowHeight()) : 0;
|
|
13640
|
+
}
|
|
13641
|
+
else {
|
|
13642
|
+
this.translateY = (scrollArgs.offset.top - (outBuffer * rowHeight) > 0) ?
|
|
13643
|
+
scrollArgs.offset.top - (outBuffer * rowHeight) + rowHeight : 0;
|
|
13644
|
+
}
|
|
13331
13645
|
}
|
|
13332
13646
|
else if (this.parent.getFrozenColumns() > 0) {
|
|
13333
13647
|
scrollArgs.offset.top = scrollArgs.offset.top + 80;
|
|
@@ -13361,6 +13675,10 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
|
|
|
13361
13675
|
((this.startIndex - currentViewData[0][`${indexValue}`]) < (this.parent.pageSettings.pageSize / 2)) && this.parent.selectionModule.isRowSelected) {
|
|
13362
13676
|
this.startIndex = currentViewData[0][`${indexValue}`] + (this.parent.pageSettings.pageSize / 2);
|
|
13363
13677
|
}
|
|
13678
|
+
if (this.parent.root.isSelfReference) {
|
|
13679
|
+
const selectedIndex = this.parent.root.selectedRowIndex;
|
|
13680
|
+
this.startIndex = selectedIndex !== -1 && selectedIndex !== this.startIndex ? this.startIndex - 1 : this.startIndex;
|
|
13681
|
+
}
|
|
13364
13682
|
if (scrollArgs.offset.top > (rowHeight * this.totalRecords)) {
|
|
13365
13683
|
this.translateY = this.getTranslateY(scrollArgs.offset.top, content.getBoundingClientRect().height);
|
|
13366
13684
|
}
|
|
@@ -13369,10 +13687,7 @@ class VirtualTreeContentRenderer extends VirtualContentRenderer {
|
|
|
13369
13687
|
this.translateY = (this.totalRecords * rowHeight) - ((this.endIndex - this.startIndex) * rowHeight);
|
|
13370
13688
|
}
|
|
13371
13689
|
else {
|
|
13372
|
-
if (this.parent.
|
|
13373
|
-
this.translateY = scrollArgs.offset.top - rowHeight * 2;
|
|
13374
|
-
}
|
|
13375
|
-
else if (this.parent.getFrozenColumns() > 0) {
|
|
13690
|
+
if (this.parent.getFrozenColumns() > 0) {
|
|
13376
13691
|
this.translateY = scrollArgs.offset.top - ((rowHeight * 2) + this.parent.pageSettings.pageSize);
|
|
13377
13692
|
}
|
|
13378
13693
|
else {
|
|
@@ -13724,6 +14039,11 @@ class VirtualScroll {
|
|
|
13724
14039
|
(startIndex < this.parent.getRows().length && endIndex <= startIndex + this.parent.getRows().length) && translateY === 0) {
|
|
13725
14040
|
startIndex = 0;
|
|
13726
14041
|
}
|
|
14042
|
+
if ((pageingDetails.actionArgs.requestType === 'save' && startIndex !== this.prevstartIndex) &&
|
|
14043
|
+
(startIndex < this.parent.getRows().length && endIndex <= startIndex + this.parent.getRows().length) && translateY === 0) {
|
|
14044
|
+
startIndex = 0;
|
|
14045
|
+
endIndex = startIndex + this.parent.grid.pageSettings.pageSize;
|
|
14046
|
+
}
|
|
13727
14047
|
if (!isNullOrUndefined(this.expandCollapseRec)) {
|
|
13728
14048
|
const resourceCount = this.parent.getRows();
|
|
13729
14049
|
let sIndex = visualData.indexOf(this.expandCollapseRec);
|