@syncfusion/ej2-treegrid
Advanced tools
Comparing version 17.1.42 to 17.1.44
@@ -5,2 +5,8 @@ # Changelog | ||
### TreeGrid | ||
#### Bug Fixes | ||
- Adding a new record or Deleting an existing record is working fine with the sorted data. | ||
## 17.1.41 (2019-04-16) | ||
@@ -7,0 +13,0 @@ |
/*! | ||
* filename: index.d.ts | ||
* version : 17.1.42 | ||
* version : 17.1.44 | ||
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved. | ||
@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license. |
{ | ||
"name": "@syncfusion/ej2-treegrid", | ||
"version": "17.1.42", | ||
"version": "17.1.44", | ||
"description": "Essential JS 2 TreeGrid Component", | ||
@@ -11,6 +11,6 @@ "author": "Syncfusion Inc.", | ||
"dependencies": { | ||
"@syncfusion/ej2-base": "~17.1.42", | ||
"@syncfusion/ej2-base": "~17.1.43", | ||
"@syncfusion/ej2-data": "~17.1.42", | ||
"@syncfusion/ej2-popups": "~17.1.42", | ||
"@syncfusion/ej2-grids": "~17.1.42" | ||
"@syncfusion/ej2-grids": "~17.1.44" | ||
}, | ||
@@ -17,0 +17,0 @@ "devDependencies": {}, |
import { Grid, ContextMenu as cmenu } from '@syncfusion/ej2-grids'; | ||
import { isNullOrUndefined } from '@syncfusion/ej2-base'; | ||
/** | ||
@@ -31,2 +32,3 @@ * ContextMenu Module for TreeGrid | ||
var addRow = args.element.querySelector('#' + this.parent.element.id + '_gridcontrol_cmenu_AddRow'); | ||
var editRecord = args.element.querySelector('#' + this.parent.element.id + '_gridcontrol_cmenu_Edit'); | ||
if (addRow) { | ||
@@ -40,2 +42,5 @@ if (this.parent.grid.editSettings.allowAdding === false) { | ||
} | ||
if (this.parent.editSettings.mode === 'Cell' && !(isNullOrUndefined(editRecord)) && !(editRecord.classList.contains('e-menu-hide'))) { | ||
editRecord.style.display = 'none'; | ||
} | ||
}; | ||
@@ -42,0 +47,0 @@ ContextMenu.prototype.contextMenuClick = function (args) { |
@@ -9,7 +9,7 @@ /** | ||
action: string; | ||
}, control: TreeGrid, isSelfReference: boolean, addRowIndex: number, selectedIndex: number, columnName?: string): void; | ||
}, control: TreeGrid, isSelfReference: boolean, addRowIndex: number, selectedIndex: number, columnName?: string, addRowRecord?: ITreeData): void; | ||
export declare function addAction(details: { | ||
value: ITreeData; | ||
action: string; | ||
}, treeData: Object[], control: TreeGrid, isSelfReference: boolean, addRowIndex: number, selectedIndex: number): { | ||
}, treeData: Object[], control: TreeGrid, isSelfReference: boolean, addRowIndex: number, selectedIndex: number, addRowRecord: ITreeData): { | ||
value: Object; | ||
@@ -16,0 +16,0 @@ isSkip: boolean; |
import { isNullOrUndefined, extend } from '@syncfusion/ej2-base'; | ||
import { DataManager } from '@syncfusion/ej2-data'; | ||
import { extendArray, getPlainData } from '../utils'; | ||
export function editAction(details, control, isSelfReference, addRowIndex, selectedIndex, columnName) { | ||
export function editAction(details, control, isSelfReference, addRowIndex, selectedIndex, columnName, addRowRecord) { | ||
var value = details.value; | ||
var action = details.action; | ||
if (action === 'save') { | ||
action = 'edit'; | ||
} | ||
var i; | ||
@@ -20,3 +17,3 @@ var j; | ||
if (action === 'add') { | ||
var addAct = addAction(details, treeData, control, isSelfReference, addRowIndex, selectedIndex); | ||
var addAct = addAction(details, treeData, control, isSelfReference, addRowIndex, selectedIndex, addRowRecord); | ||
value = addAct.value; | ||
@@ -113,3 +110,3 @@ isSkip = addAct.isSkip; | ||
} | ||
export function addAction(details, treeData, control, isSelfReference, addRowIndex, selectedIndex) { | ||
export function addAction(details, treeData, control, isSelfReference, addRowIndex, selectedIndex, addRowRecord) { | ||
var value; | ||
@@ -130,7 +127,17 @@ var isSkip = false; | ||
case 'Above': | ||
value = currentViewRecords[addRowIndex + 1]; | ||
if (!isNullOrUndefined(addRowRecord)) { | ||
value = addRowRecord; | ||
} | ||
else { | ||
value = currentViewRecords[addRowIndex + 1]; | ||
} | ||
break; | ||
case 'Below': | ||
case 'Child': | ||
value = currentViewRecords[addRowIndex]; | ||
if (!isNullOrUndefined(addRowRecord)) { | ||
value = addRowRecord; | ||
} | ||
else { | ||
value = currentViewRecords[addRowIndex]; | ||
} | ||
if (selectedIndex === -1) { | ||
@@ -208,3 +215,13 @@ treeData.unshift(value); | ||
record.hasChildRecords = true; | ||
var childRecords = child ? child : currentRecords[index + 1]; | ||
if (control.sortSettings.columns.length && isNullOrUndefined(child)) { | ||
child = currentRecords.filter(function (e) { | ||
if (e.parentUniqueID === record.uniqueID) { | ||
return e; | ||
} | ||
else { | ||
return null; | ||
} | ||
}); | ||
} | ||
var childRecords = child ? child instanceof Array ? child[0] : child : currentRecords[index + 1]; | ||
if (!record.hasOwnProperty('childRecords')) { | ||
@@ -211,0 +228,0 @@ record.childRecords = []; |
@@ -12,2 +12,3 @@ import { Column } from '@syncfusion/ej2-grids'; | ||
private addRowIndex; | ||
private addRowRecord; | ||
private isOnBatch; | ||
@@ -57,2 +58,3 @@ private keyPress; | ||
private crudAction; | ||
private updateIndex; | ||
private beginAdd; | ||
@@ -76,2 +78,3 @@ private beginEdit; | ||
destroyForm(): void; | ||
private contentready; | ||
} |
import { Grid, Edit as GridEdit, getUid, getObject } from '@syncfusion/ej2-grids'; | ||
import * as events from '../base/constant'; | ||
import { isNullOrUndefined, extend, setValue, removeClass } from '@syncfusion/ej2-base'; | ||
import { isNullOrUndefined, extend, setValue, removeClass, addClass, getValue } from '@syncfusion/ej2-base'; | ||
import { DataManager } from '@syncfusion/ej2-data'; | ||
@@ -43,2 +43,3 @@ import { findChildrenRecords } from '../utils'; | ||
this.parent.grid.on(events.keyPressed, this.keyPressed, this); | ||
this.parent.grid.on('content-ready', this.contentready, this); | ||
this.parent.on(events.cellEdit, this.cellEdit, this); | ||
@@ -82,2 +83,3 @@ this.parent.grid.on(events.doubleTap, this.recordDoubleClick, this); | ||
this.parent.grid.off(events.keyPressed, this.keyPressed); | ||
this.parent.grid.off('content-ready', this.contentready); | ||
this.parent.off(events.cellEdit, this.cellEdit); | ||
@@ -171,5 +173,7 @@ this.parent.grid.off(events.doubleTap, this.recordDoubleClick); | ||
if (this.parent.editSettings.mode === 'Cell') { | ||
var cellDetails = getValue('editModule.cellDetails', this.parent.grid.editModule); | ||
var selectRowIndex = cellDetails.rowIndex; | ||
this.parent.renderModule.cellRender({ | ||
data: this.parent.grid.getSelectedRecords()[0], | ||
cell: this.parent.grid.getSelectedRows()[0].cells[this.parent.treeColumnIndex], | ||
data: cellDetails.rowData, | ||
cell: this.parent.getRows()[selectRowIndex].cells[this.parent.treeColumnIndex], | ||
column: this.parent.grid.getColumns()[this.parent.treeColumnIndex] | ||
@@ -236,3 +240,3 @@ }); | ||
removeClass(row.querySelectorAll('.e-rowcell'), ['e-editedbatchcell', 'e-updatedtd']); | ||
editAction({ value: args.rowData, action: 'edit' }, this.parent, this.isSelfReference, this.addRowIndex, this.selectedIndex, args.columnName); | ||
editAction({ value: args.rowData, action: 'edit' }, this.parent, this.isSelfReference, this.addRowIndex, this.selectedIndex, args.columnName, this.addRowRecord); | ||
var saveArgs = { | ||
@@ -254,3 +258,12 @@ type: 'save', column: this.parent.getColumnByField(args.columnName), data: args.rowData, | ||
Edit.prototype.crudAction = function (details, columnName) { | ||
editAction(details, this.parent, this.isSelfReference, this.addRowIndex, this.selectedIndex, columnName); | ||
editAction(details, this.parent, this.isSelfReference, this.addRowIndex, this.selectedIndex, columnName, this.addRowRecord); | ||
this.parent.parentData = []; | ||
var data = this.parent.grid.dataSource; | ||
for (var i = 0; i < this.parent.grid.dataSource.length; i++) { | ||
data[i].index = i; | ||
setValue('uniqueIDCollection.' + data[i].uniqueID + '.index', i, this.parent); | ||
if (!data[i].level) { | ||
this.parent.parentData.push(data[i]); | ||
} | ||
} | ||
if (details.action === 'add' && this.previousNewRowPosition != null) { | ||
@@ -261,2 +274,31 @@ this.parent.setProperties({ editSettings: { newRowPosition: this.previousNewRowPosition } }, true); | ||
}; | ||
Edit.prototype.updateIndex = function (data, rows, records) { | ||
for (var j = 0; j < this.parent.getRows().length; j++) { | ||
var data1 = records[j]; | ||
var index = getValue('uniqueIDCollection.' + data1.uniqueID + '.index', this.parent); | ||
data1.index = index; | ||
if (!isNullOrUndefined(data1.parentItem)) { | ||
var parentIndex = getValue('uniqueIDCollection.' + data1.parentItem.uniqueID + '.index', this.parent); | ||
data1.parentItem.index = parentIndex; | ||
} | ||
} | ||
for (var k = 0; k < this.parent.getRows().length; k++) { | ||
var data2 = records[k]; | ||
var index = data2.index; | ||
var level = data2.level; | ||
var row = rows[k]; | ||
if (!isNullOrUndefined(data2.parentItem)) { | ||
index = getValue('uniqueIDCollection.' + data2.parentItem.uniqueID + '.index', this.parent); | ||
} | ||
for (var l = 0; l < row.classList.length; l++) { | ||
var value = row.classList[l]; | ||
var remove = /e-gridrowindex/i; | ||
var result = value.match(remove); | ||
if (result != null) { | ||
removeClass([row], value); | ||
} | ||
} | ||
addClass([row], 'e-gridrowindex' + index + 'level' + level); | ||
} | ||
}; | ||
Edit.prototype.beginAdd = function (args) { | ||
@@ -346,2 +388,3 @@ var position; | ||
this.addRowIndex = this.parent.grid.selectedRowIndex > -1 ? this.parent.grid.selectedRowIndex : 0; | ||
this.addRowRecord = this.parent.getSelectedRecords()[0]; | ||
} | ||
@@ -393,6 +436,9 @@ args = this.beginAddEdit(args); | ||
position = 'before'; | ||
index = currentData[this.addRowIndex].index; | ||
} | ||
else if (this.parent.editSettings.newRowPosition === 'Below') { | ||
position = 'after'; | ||
index += findChildrenRecords(currentData[this.addRowIndex]).length; | ||
var childRecordCount = findChildrenRecords(currentData[this.addRowIndex]).length; | ||
var currentDataIndex = currentData[this.addRowIndex].index; | ||
index = (childRecordCount > 0) ? (currentDataIndex + childRecordCount) : (currentDataIndex); | ||
} | ||
@@ -407,3 +453,5 @@ else if (this.parent.editSettings.newRowPosition === 'Child') { | ||
} | ||
index += findChildrenRecords(currentData[this.addRowIndex]).length; | ||
var childRecordCount1 = findChildrenRecords(currentData[this.addRowIndex]).length; | ||
var currentDataIndex1 = currentData[this.addRowIndex].index; | ||
index = (childRecordCount1 > 0) ? (currentDataIndex1 + childRecordCount1) : (currentDataIndex1); | ||
value.level = level + 1; | ||
@@ -485,4 +533,10 @@ if (this.isSelfReference) { | ||
}; | ||
Edit.prototype.contentready = function (e) { | ||
if (!isNullOrUndefined(e.args.requestType) | ||
&& (e.args.requestType.toString() === 'delete' || e.args.requestType.toString() === 'save')) { | ||
this.updateIndex(this.parent.grid.dataSource, this.parent.getRows(), this.parent.getCurrentViewRecords()); | ||
} | ||
}; | ||
return Edit; | ||
}()); | ||
export { Edit }; |
@@ -289,2 +289,19 @@ import { extend, isNullOrUndefined, setValue, getValue } from '@syncfusion/ej2-base'; | ||
var dataObj; | ||
var actionArgs = getObject('actionArgs', args); | ||
var requestType = getObject('requestType', args); | ||
var actionData = getObject('data', args); | ||
var action = getObject('action', args); | ||
if ((!isNullOrUndefined(actionArgs) && Object.keys(actionArgs).length) || requestType === 'save') { | ||
requestType = requestType ? requestType : actionArgs.requestType.toString(); | ||
actionData = actionData ? actionData : getObject('data', actionArgs); | ||
action = action ? action : getObject('action', actionArgs); | ||
if (action === 'add') { | ||
this.parent.grid.currentViewData = args.result; | ||
} | ||
if (this.parent.isLocalData) { | ||
if ((requestType === 'delete' || requestType === 'save')) { | ||
this.parent.notify(events.crudAction, { value: actionData, action: action || requestType }); | ||
} | ||
} | ||
} | ||
if (isExport && !isNullOrUndefined(expresults)) { | ||
@@ -336,3 +353,3 @@ dataObj = expresults; | ||
var parentData = void 0; | ||
var action = 'action'; | ||
var action_1 = 'action'; | ||
var collpasedIndexes = []; | ||
@@ -339,0 +356,0 @@ parentData = this.parent.parentData; |
@@ -273,2 +273,12 @@ import { Component, addClass, createElement, EventHandler, isNullOrUndefined, Ajax, ModuleDeclaration, extend} from '@syncfusion/ej2-base';import { removeClass, EmitType, Complex, Collection, KeyboardEventArgs } from '@syncfusion/ej2-base';import {Event, Property, NotifyPropertyChanges, INotifyPropertyChanged, setValue, KeyboardEvents, L10n } from '@syncfusion/ej2-base';import { Column, ColumnModel } from '../models/column';import { GridModel, ColumnQueryModeType, HeaderCellInfoEventArgs, EditSettingsModel as GridEditModel} from '@syncfusion/ej2-grids';import { SearchEventArgs, AddEventArgs, EditEventArgs, DeleteEventArgs} from '@syncfusion/ej2-grids';import { SaveEventArgs, CellSaveArgs, BatchAddArgs, BatchCancelArgs, BeginEditArgs, CellEditArgs} from '@syncfusion/ej2-grids';import { FilterSettings } from '../models/filter-settings';import {Filter} from '../actions/filter';import {Aggregate} from '../actions/summary';import { Reorder } from '../actions/reorder';import { Resize } from '../actions/resize';import { Selection as TreeGridSelection } from '../actions/selection';import { ColumnMenu } from '../actions/column-menu';import { Print } from '../actions/print';import * as events from '../base/constant';import { FilterSettingsModel } from '../models/filter-settings-model';import { SearchSettings} from '../models/search-settings';import { SearchSettingsModel } from '../models/search-settings-model';import {RowInfo, RowDataBoundEventArgs, PageEventArgs, FilterEventArgs, FailureEventArgs, SortEventArgs } from '@syncfusion/ej2-grids';import { RowSelectingEventArgs, RowSelectEventArgs, RowDeselectEventArgs, IIndex, ISelectedCell } from '@syncfusion/ej2-grids';import {ColumnModel as GridColumnModel, Column as GridColumn, CellSelectEventArgs, CellDeselectEventArgs } from '@syncfusion/ej2-grids';import { SelectionSettings } from '../models/selection-settings';import { SelectionSettingsModel } from '../models/selection-settings-model';import {getActualProperties, SortDirection, getObject, ColumnDragEventArgs } from '@syncfusion/ej2-grids';import { TextWrapSettings, TextWrapSettingsModel, PrintMode, Data, IGrid, ContextMenuItemModel } from '@syncfusion/ej2-grids';import { ColumnMenuItem, ColumnMenuItemModel, CheckBoxChangeEventArgs } from '@syncfusion/ej2-grids';import { ExcelExportCompleteArgs, ExcelHeaderQueryCellInfoEventArgs, ExcelQueryCellInfoEventArgs } from '@syncfusion/ej2-grids';import { PdfExportCompleteArgs, PdfHeaderQueryCellInfoEventArgs, PdfQueryCellInfoEventArgs } from '@syncfusion/ej2-grids';import { ExcelExportProperties, PdfExportProperties, CellSelectingEventArgs, PrintEventArgs } from '@syncfusion/ej2-grids';import { ColumnMenuOpenEventArgs } from '@syncfusion/ej2-grids';import {BeforeDataBoundArgs} from '@syncfusion/ej2-grids';import { DataManager, ReturnOption, RemoteSaveAdaptor, Query } from '@syncfusion/ej2-data';import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';import { isRemoteData, isOffline } from '../utils';import { Grid, QueryCellInfoEventArgs } from '@syncfusion/ej2-grids';import { Render } from '../renderer/render';import { DataManipulation } from './data';import { Sort } from '../actions/sort';import { ITreeData, RowExpandedEventArgs, RowExpandingEventArgs, RowCollapsedEventArgs, RowCollapsingEventArgs } from './interface';import { CellSaveEventArgs } from './interface';import { iterateArrayOrObject, GridLine } from '@syncfusion/ej2-grids';import { DataSourceChangedEventArgs, DataStateChangeEventArgs, RecordDoubleClickEventArgs, ResizeArgs } from '@syncfusion/ej2-grids';import { ToolbarItems, ToolbarItem, ContextMenuItem, ContextMenuItems, RowPosition } from '../enum';import { ItemModel, ClickEventArgs, BeforeOpenCloseMenuEventArgs, MenuEventArgs } from '@syncfusion/ej2-navigations';import { PageSettings } from '../models/page-settings';import { PageSettingsModel } from '../models/page-settings-model';import { AggregateRow } from '../models/summary';import { AggregateRowModel } from '../models/summary-model';import { ExcelExport } from '../actions/excel-export';import { PdfExport } from '../actions/pdf-export';import { Toolbar } from '../actions/toolbar';import { Page } from '../actions/page';import { ContextMenu } from '../actions/context-menu';import { EditSettings } from '../models/edit-settings';import { EditSettingsModel } from '../models/edit-settings-model';import { Edit} from '../actions/edit';import { SortSettings } from '../models/sort-settings';import { SortSettingsModel } from '../models/sort-settings-model'; | ||
/** | ||
* The row template that renders customized rows from the given template. | ||
* By default, TreeGrid renders a table row for every data source item. | ||
* > * It accepts either [template string](../../common/template-engine.html) or HTML element ID. | ||
* > * The row template must be a table row. | ||
* | ||
* > Check the [`Row Template`](../../treegrid/row) customization. | ||
*/ | ||
rowTemplate?: string; | ||
/** | ||
* Defines the height of TreeGrid rows. | ||
@@ -275,0 +285,0 @@ * @default null |
@@ -356,2 +356,11 @@ import { Component, ModuleDeclaration } from '@syncfusion/ej2-base'; | ||
/** | ||
* The row template that renders customized rows from the given template. | ||
* By default, TreeGrid renders a table row for every data source item. | ||
* > * It accepts either [template string](../../common/template-engine.html) or HTML element ID. | ||
* > * The row template must be a table row. | ||
* | ||
* > Check the [`Row Template`](../../treegrid/row) customization. | ||
*/ | ||
rowTemplate: string; | ||
/** | ||
* Defines the height of TreeGrid rows. | ||
@@ -358,0 +367,0 @@ * @default null |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2764198
25596