UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

1,083 lines (1,082 loc) 220 kB
import { __extends, __values } from "tslib"; import { IgcSectionHeaderComponent } from './igc-section-header-component'; import { IgcSummaryRowRootComponent } from './igc-summary-row-root-component'; import { IgcSummaryRowSectionComponent } from './igc-summary-row-section-component'; import { IgcColumnWidth } from './igc-column-width'; import { ColumnWidth as ColumnWidth_internal } from './ColumnWidth'; import { HeaderClickAction_$type } from './HeaderClickAction'; import { ColumnShowingAnimationMode_$type } from './ColumnShowingAnimationMode'; import { ColumnPropertyUpdatingAnimationMode, ColumnPropertyUpdatingAnimationMode_$type } from './ColumnPropertyUpdatingAnimationMode'; import { CellDataLoadedAnimationMode_$type } from './CellDataLoadedAnimationMode'; import { RowSelectionAnimationMode_$type } from './RowSelectionAnimationMode'; import { ColumnMovingAnimationMode_$type } from './ColumnMovingAnimationMode'; import { ColumnHidingAnimationMode_$type } from './ColumnHidingAnimationMode'; import { CellSelectionAnimationMode_$type } from './CellSelectionAnimationMode'; import { ColumnExchangingAnimationMode_$type } from './ColumnExchangingAnimationMode'; import { RowHoverAnimationMode_$type } from './RowHoverAnimationMode'; import { DataGridSelectionMode_$type } from './DataGridSelectionMode'; import { GridActivationMode_$type } from './GridActivationMode'; import { GridSelectionBehavior_$type } from './GridSelectionBehavior'; import { IgcDataGridCellEventArgs } from './igc-data-grid-cell-event-args'; import { IgcGridColumnsAutoGeneratedEventArgs } from './igc-grid-columns-auto-generated-event-args'; import { IgcGridSelectedItemsChangedEventArgs } from './igc-grid-selected-items-changed-event-args'; import { IgcGridSelectedKeysChangedEventArgs } from './igc-grid-selected-keys-changed-event-args'; import { IgcGridSelectedCellsChangedEventArgs } from './igc-grid-selected-cells-changed-event-args'; import { IgcGridSelectedCellRangesChangedEventArgs } from './igc-grid-selected-cell-ranges-changed-event-args'; import { IgcGridSortDescriptionsChangedEventArgs } from './igc-grid-sort-descriptions-changed-event-args'; import { IgcGridGroupDescriptionsChangedEventArgs } from './igc-grid-group-descriptions-changed-event-args'; import { IgcGridSummaryDescriptionsChangedEventArgs } from './igc-grid-summary-descriptions-changed-event-args'; import { DataGrid } from "./DataGrid"; import { ensureEnum, ensureBool, CollectionAdapter, getAllPropertyNames, enumToString, fromSpinal, toSpinal, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher } from "igniteui-webcomponents-core"; import { Thickness } from "igniteui-webcomponents-core"; import { WebComponentRenderer, WebComponentWrapper, PortalManager } from "igniteui-webcomponents-core"; import { DataGridColumn } from './DataGridColumn'; import { IgcDataGridColumnComponent } from './igc-data-grid-column-component'; import { DataGridCellLayoutPanel } from './DataGridCellLayoutPanel'; import { Base } from "igniteui-webcomponents-core"; import { GridExternalWrapper } from './GridExternalWrapper'; import { BrowserTickProvider } from './BrowserTickProvider'; import { BrowserPixelConverter } from './BrowserPixelConverter'; import { DataGridPresenterManager } from './DataGridPresenterManager'; import { DataGridViewportManager } from './DataGridViewportManager'; import { DataGridDelayedExecutionManager } from './DataGridDelayedExecutionManager'; import { DataGridPropertySetter } from './DataGridPropertySetter'; import { IgcGridColumnCollection } from './igc-grid-column-collection'; import { SyncableObservableCollection$1 } from "igniteui-webcomponents-core"; import { NotifyCollectionChangedAction } from "igniteui-webcomponents-core"; import { Scroller } from "igniteui-webcomponents-core"; import { ScrollbarStyle_$type } from "igniteui-webcomponents-core"; import { Dragger } from "./Dragger"; import { DataGridStylingDefaults } from './DataGridStylingDefaults'; import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { FontInfo } from "igniteui-webcomponents-core"; import { IgcColumnSortDescriptionCollection } from './igc-column-sort-description-collection'; import { IgcColumnGroupDescriptionCollection } from './igc-column-group-description-collection'; import { IgcFilterExpressionCollection } from "igniteui-webcomponents-core"; import { IgcColumnSummaryDescriptionCollection } from './igc-column-summary-description-collection'; import { IgcGridSelectedItemsCollection } from "./igc-grid-selected-items-collection"; import { IgcGridSelectedKeysCollection } from "./igc-grid-selected-keys-collection"; import { IgcGridSelectedCellsCollection } from "./igc-grid-selected-cells-collection"; import { IgcGridSelectedCellRangesCollection } from "./igc-grid-selected-cell-ranges-collection"; import { GridSelectedItemsCollection as GridSelectedItemsCollection_internal } from "./GridSelectedItemsCollection"; import { GridSelectedKeysCollection as GridSelectedKeysCollection_internal } from "./GridSelectedKeysCollection"; import { GridSelectedCellsCollection as GridSelectedCellsCollection_internal } from "./GridSelectedCellsCollection"; import { GridSelectedCellRangesCollection as GridSelectedCellRangesCollection_internal } from "./GridSelectedCellRangesCollection"; import { PrimaryKeyValue } from "./PrimaryKeyValue"; import { CellKey } from "./CellKey"; import { CellRange } from "./CellRange"; import { IgcGridFilterExpressionsEventArgs } from './igc-grid-filter-expressions-event-args'; import { GridColumnCollection as GridColumnCollection_internal } from './GridColumnCollection'; import { ResponsiveStatesCollection as ResponsiveStatesCollection_internal } from './ResponsiveStatesCollection'; import { IgcResponsiveStatesCollection } from './igc-responsive-states-collection'; import { ResponsiveState } from './ResponsiveState'; import { IgcGridAnimationSettings } from './igc-grid-animation-settings'; import { IgcRowSeparatorComponent } from './igc-row-separator-component'; import { IgcHeaderRowSeparatorComponent } from './igc-header-row-separator-component'; import { IgcGridCellPosition } from "./igc-grid-cell-position"; import { IgcGridActiveCellChangedEventArgs } from "./igc-grid-active-cell-changed-event-args"; import { IgcColumnHiddenChangedEventArgs } from "./igc-column-hidden-changed-event-args"; import { DataGridScrollerKeyboardListener } from "./DataGridScrollerKeyboardListener"; import { IgcHeaderSeparatorComponent } from "./igc-header-separator-component"; import { IgcColumnResizingSeparatorComponent } from './igc-column-resizing-separator-component'; import { ColumnResizingMode_$type } from "./ColumnResizingMode"; import { ColumnResizingAnimationMode_$type } from "./ColumnResizingAnimationMode"; import { ColumnMovingMode_$type } from "./ColumnMovingMode"; import { IgcColumnMovingSeparatorComponent } from "./igc-column-moving-separator-component"; import { SortIndicatorStyle_$type } from "./SortIndicatorStyle"; import { GroupHeaderDisplayMode_$type } from "./GroupHeaderDisplayMode"; import { SummaryScope_$type } from "./SummaryScope"; import { GroupSummaryDisplayMode_$type } from "./GroupSummaryDisplayMode"; import { fromRect } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcPinnedAreaSeparatorComponent } from "./igc-pinned-area-separator-component"; import { ColumnOptionsIconAlignment_$type } from "./ColumnOptionsIconAlignment"; import { ColumnOptionsIconBehavior_$type } from "./ColumnOptionsIconBehavior"; import { IgcColumnPinnedChangedEventArgs } from "./igc-column-pinned-changed-event-args"; import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core"; import { CornerRadius } from "igniteui-webcomponents-core"; import { EditModeType_$type } from "./EditModeType"; import { EditModeClickAction_$type } from "./EditModeClickAction"; import { IgcGridCellValueChangingEventArgs } from "./igc-grid-cell-value-changing-event-args"; import { IgcGridDataCommittingEventArgs } from "./igc-grid-data-committing-event-args"; import { IgcGridDataCommittedEventArgs } from "./igc-grid-data-committed-event-args"; import { IgcGridSizeChangedEventArgs } from "./igc-grid-size-changed-event-args"; import { IgcGridColumnsChangedEventArgs } from './igc-grid-columns-changed-event-args'; import { IgcGridColumnWidthChangedEventArgs } from "./igc-grid-column-width-changed-event-args"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; import { DataGridAccessibilityLayoutPanel } from './DataGridAccessibilityLayoutPanel'; import { IgcGridCellEditStartedEventArgs } from "./igc-grid-cell-edit-started-event-args"; import { IgcGridCellEditEndedEventArgs } from "./igc-grid-cell-edit-ended-event-args"; import { IgcGridRowEditStartedEventArgs } from "./igc-grid-row-edit-started-event-args"; import { IgcGridRowEditEndedEventArgs } from "./igc-grid-row-edit-ended-event-args"; import { IgcGridSelectionChangedEventArgs } from "./igc-grid-selection-changed-event-args"; import { EnterKeyBehaviors_$type } from "./EnterKeyBehaviors"; import { EnterKeyBehaviorAfterEdit_$type } from "./EnterKeyBehaviorAfterEdit"; import { MergedCellMode_$type } from "./MergedCellMode"; import { MergedCellEvaluationCriteria_$type } from "./MergedCellEvaluationCriteria"; import { FilterUIType, FilterUIType_$type } from "./FilterUIType"; import { FilterLogicalOperator_$type } from "./FilterLogicalOperator"; import { FilterComparisonType_$type } from "./FilterComparisonType"; import { IgcGridCustomFilterRequestedEventArgs } from "./igc-grid-custom-filter-requested-event-args"; import { ColumnGrouping } from "./ColumnGrouping"; import { IgcDateTimeCellInfo } from "./igc-date-time-cell-info"; import { IgcImageCellInfo } from "./igc-image-cell-info"; import { IgcNumericCellInfo } from "./igc-numeric-cell-info"; import { IgcRowSeparatorInfo } from "./igc-row-separator-info"; import { IgcSectionHeaderCellInfo } from "./igc-section-header-cell-info"; import { IgcTemplateCellInfo } from "./igc-template-cell-info"; import { IgcTemplateHeaderCellInfo } from "./igc-template-header-cell-info"; import { IgcTemplateSectionHeaderCellInfo } from "./igc-template-section-header-cell-info"; import { IgcTextCellInfo } from "./igc-text-cell-info"; import { IgcTextHeaderCellInfo } from "./igc-text-header-cell-info"; import { IgcFilterCellInfo } from "./igc-filter-cell-info"; import { CellContentVerticalAlignment_$type } from "./CellContentVerticalAlignment"; import { IgcDataSourceRootSummariesChangedEventArgs } from "igniteui-webcomponents-core"; var GridStylingDefaults = {}; var IgcDataGridComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcDataGridComponent, _super); function IgcDataGridComponent() { var _this = _super.call(this) || this; _this.contentColumns = []; /** * The columns actually present in the grid. Do not directly modify this array. * This array's contents can be modified by causing WC to reproject the child content. * Or adding and removing columns from the columns property. */ _this.combinedColumns = []; _this._disableManualColumnSync = false; _this._columns = null; _this._columnsAdapter = null; _this._renderer = null; _this._disconnected = false; _this._initialized = false; _this._scroller = null; _this._wrapper = null; _this._grid = null; _this.containerResized = function () { var width = this._container.getNativeElement().clientWidth; var height = this._container.getNativeElement().clientHeight; this._scroller.viewportWidth = width; this._scroller.viewportHeight = height; this._scroller.verticalTrackStartInset = this.getVerticalTrackStartInset(); this._grid.dragger.viewportWidth = width; this._grid.dragger.viewportHeight = height; this._grid.onSizeChanged(width, height); if (this._grid.model.actualVisibleRegion.isEmpty && width > 0 && height > 0) { this._grid.setViewport(0, 0, width, height); } else { this.onScroll(); } }; _this._dataSource = null; _this._insetLeft = 0; _this._insetTop = 0; _this._insetRight = 0; _this._insetBottom = 0; _this._hasParentAdded = false; _this._isGroupByAreaVisible = false; _this._hasColumnGroupingAdded = false; _this._isPagerVisible = false; _this._settingAttributes = false; _this._attached = false; _this._queuedSetAttributes = []; _this._updatingFromAttribute = false; _this._selectedItems = null; _this._selectedKeys = null; _this._selectedCells = null; _this._selectedCellRanges = null; _this._pinnedItems = null; _this._pinnedKeys = null; _this._responsiveStates = null; _this._actualColumns = null; _this.__p = null; _this._hasUserValues = new Set(); _this._stylingContainer = null; _this._stylingParent = null; _this._inStyling = false; _this._filterExpressionsChanging = null; _this._filterExpressionsChanging_wrapped = null; _this._filterExpressionsChanged = null; _this._filterExpressionsChanged_wrapped = null; _this._cellPreviewPointerDown = null; _this._cellPreviewPointerDown_wrapped = null; _this._cellPreviewPointerUp = null; _this._cellPreviewPointerUp_wrapped = null; _this._cellPointerDown = null; _this._cellPointerDown_wrapped = null; _this._cellPointerUp = null; _this._cellPointerUp_wrapped = null; _this._cellClicked = null; _this._cellClicked_wrapped = null; _this._sortDescriptionsChanged = null; _this._sortDescriptionsChanged_wrapped = null; _this._groupDescriptionsChanged = null; _this._groupDescriptionsChanged_wrapped = null; _this._summaryDescriptionsChanged = null; _this._summaryDescriptionsChanged_wrapped = null; _this._columnHiddenChanged = null; _this._columnHiddenChanged_wrapped = null; _this._columnPinnedChanged = null; _this._columnPinnedChanged_wrapped = null; _this._cellValueChanging = null; _this._cellValueChanging_wrapped = null; _this._dataCommitted = null; _this._dataCommitted_wrapped = null; _this._dataCommitting = null; _this._dataCommitting_wrapped = null; _this._rootSummariesChanged = null; _this._rootSummariesChanged_wrapped = null; _this._sizeChanged = null; _this._sizeChanged_wrapped = null; _this._actualColumnsChanged = null; _this._actualColumnsChanged_wrapped = null; _this._columnsAutoGenerated = null; _this._columnsAutoGenerated_wrapped = null; _this._selectedItemsChanged = null; _this._selectedItemsChanged_wrapped = null; _this._selectedKeysChanged = null; _this._selectedKeysChanged_wrapped = null; _this._selectedCellsChanged = null; _this._selectedCellsChanged_wrapped = null; _this._selectionChanged = null; _this._selectionChanged_wrapped = null; _this._activeCellChanged = null; _this._activeCellChanged_wrapped = null; _this._selectedCellRangesChanged = null; _this._selectedCellRangesChanged_wrapped = null; _this._columnWidthChanged = null; _this._columnWidthChanged_wrapped = null; _this._cellEditStarted = null; _this._cellEditStarted_wrapped = null; _this._cellEditEnded = null; _this._cellEditEnded_wrapped = null; _this._rowEditStarted = null; _this._rowEditStarted_wrapped = null; _this._rowEditEnded = null; _this._rowEditEnded_wrapped = null; _this._customFilterRequested = null; _this._customFilterRequested_wrapped = null; _this._actualPrimaryKeyChange = null; _this._actualPrimaryKeyChange_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._portalManager = new PortalManager("filterDialog"); _this._renderer = new WebComponentRenderer(_this, document, true, DataGridStylingDefaults, _this._portalManager); _this._container = _this._renderer.createElement("div"); //this._renderer.rootWrapper.append(this._container); //this._renderer.rootWrapper.setStyleProperty("display", "block"); _this._renderer.updateRoot(_this._container); _this._renderer.rootWrapper.setStyleProperty("display", "block"); _this._renderer.rootWrapper.setStyleProperty("width", "100%"); _this._renderer.rootWrapper.setStyleProperty("height", "100%"); _this._renderer.rootWrapper.setStyleProperty("overflow", "hidden"); var root; root = _this._container; if (_this._container.getNativeElement() != null) { root = _this._container.getNativeElement(); } _this._contentArea = _this._renderer.createElement("div"); _this._contentArea.setRawStyleProperty("overflow", "hidden"); _this._contentArea.setRawStyleProperty("flex", "1"); _this._contentArea.append(_this._renderer.rootWrapper); _this._wrapper = _this._renderer; _this._implementation = new DataGrid(); var grid = _this.i; _this._grid = grid; _this._grid.externalObject = _this; _this._columnsAdapter = new CollectionAdapter(_this.contentColumns, _this.i.columns, _this.combinedColumns, function (c) { return c.i; }, function (i) { i._provideRenderer(_this._wrapper); if (_this.parentElement) { i._styling(_this, _this, _this); } }, function (i) { i._provideRenderer(null); }, function (i) { return i.name || i.field; }); grid.externalGrid = new GridExternalWrapper(_this); grid.tickProvider = new BrowserTickProvider(_this._renderer); grid.platformPixelConverter = new BrowserPixelConverter(); var isAccessible = _this.getAttribute("use-accessibility"); if (isAccessible) { _this.useAccessibility = ensureBool(isAccessible); } //if (this.useAccessibility) { // this._contentLayout = new DataGridAccessibilityLayoutPanel(this._renderer, new DataGridPresenterManager(this._grid, this.useCanvas), window.devicePixelRatio); // this._contentLayout.rootElement = this._renderer.rootWrapper; //} else { // this._contentLayout = new DataGridCellLayoutPanel(this._renderer, new DataGridPresenterManager(this._grid, this.useCanvas), window.devicePixelRatio); //} //grid.renderingEngine = this._contentLayout; grid.viewportManager = new DataGridViewportManager(_this); grid.delayedExecutionManager = new DataGridDelayedExecutionManager(_this._renderer); grid.propertySetter = new DataGridPropertySetter(); //grid.provideContainer(ren); var scroller = new Scroller(); scroller.scrollbarStyle = _this.scrollbarStyle; _this._scroller = scroller; _this._scroller.keyboardListener = new DataGridScrollerKeyboardListener(grid); scroller.provideContainer(_this._renderer); //this._content = <Element>(this._contentLayout.element.getNativeElement()); //scroller.provideContent(new WebComponentWrapper(this._content, this._renderer)); scroller.onScrolling = function () { return _this.onScroll(); }; scroller.onScrollStart = function () { return _this.onScrollStart(); }; scroller.onScrollStop = function () { return _this.onScrollStop(); }; scroller.viewportWidth = _this._container.getNativeElement().clientWidth; scroller.viewportHeight = _this._container.getNativeElement().clientHeight; var isFilterRowEnabled = _this.filterUIType === FilterUIType.FilterRow; var filterRowHeight = isFilterRowEnabled ? _this.actualRowHeight + _this.rowSeparatorHeight : 0; scroller.verticalTrackStartInset = _this.getVerticalTrackStartInset(); //scroller.verticalTrackStartInset = this.actualHeaderHeight; grid.dragger = new Dragger(); grid.dragger.provideContainer(_this._renderer); grid.dragger.viewportWidth = _this._container.getNativeElement().clientWidth; grid.dragger.viewportHeight = _this._container.getNativeElement().clientHeight; var mut = new MutationObserver(function (list) { var e_1, _b; try { for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) { var mutation = list_1_1.value; if (mutation.type == 'childList') { _this.updateContentColumns(); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (list_1_1 && !list_1_1.done && (_b = list_1.return)) _b.call(list_1); } finally { if (e_1) throw e_1.error; } } }); mut.observe(_this, { childList: true }); _this._renderer.addSizeWatcher(function () { _this.containerResized(); }); return _this; } IgcDataGridComponent.prototype._ensureColumnsAreManual = function () { this._disableManualColumnSync = true; this._columnsAdapter.shiftContentToManual(this.columns, function (i) { return i.isFromMarkup = false; }); this._disableManualColumnSync = false; }; Object.defineProperty(IgcDataGridComponent.prototype, "columns", { /** * A collection or manually added columns for the grid. */ get: function () { var _this = this; if (this._columns === null) { var coll = new IgcGridColumnCollection(); var inner = coll._innerColl; inner.addListener(function (sender, e) { if (_this._disableManualColumnSync) { return; } switch (e.action) { case NotifyCollectionChangedAction.Add: _this._columnsAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Remove: _this._columnsAdapter.removeManualItemAt(e.oldStartingIndex); break; case NotifyCollectionChangedAction.Replace: _this._columnsAdapter.removeManualItemAt(e.oldStartingIndex); _this._columnsAdapter.insertManualItem(e.newStartingIndex, e.newItems.item(0)); break; case NotifyCollectionChangedAction.Reset: _this._columnsAdapter.clearManualItems(); break; } }); this._columns = coll; } return this._columns; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.style.height = value; this.containerResized(); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.style.width = value; this.containerResized(); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "useCanvas", { get: function () { return this._useCanvas; }, set: function (value) { this._useCanvas = ensureBool(value); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "useAccessibility", { get: function () { return this._useAccessibility; }, set: function (value) { this._useAccessibility = ensureBool(value); }, enumerable: false, configurable: true }); IgcDataGridComponent.prototype._setScrollbarStyle = function (style) { if (this._scroller) { this._scroller.scrollbarStyle = style; } }; IgcDataGridComponent.prototype._setScrollbarColor = function (color) { if (this._scroller) { this._scroller.scrollbarBrush = color; } }; IgcDataGridComponent.prototype.createImplementation = function () { //let test = Grid; return new DataGrid(); }; Object.defineProperty(IgcDataGridComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgcDataGridComponent.prototype.onImplementationCreated = function () { }; IgcDataGridComponent.prototype.getVerticalTrackStartInset = function () { var isFilterRowEnabled = this.filterUIType === FilterUIType.FilterRow; var filterRowHeight = isFilterRowEnabled ? this.actualRowHeight + this.rowSeparatorHeight : 0; return this.actualHeaderHeight + this.rowSeparatorHeight + filterRowHeight; }; IgcDataGridComponent.prototype._focusScroller = function () { this._scroller.focus(); }; IgcDataGridComponent.prototype._setDefaultCursor = function () { if (this.style.cursor !== "") { this.style.cursor = ""; } }; IgcDataGridComponent.prototype._setResizeCursor = function () { if (this.style.cursor !== "col-resize") { this.style.cursor = "col-resize"; } }; IgcDataGridComponent.prototype._setHandCursor = function () { if (this.style.cursor !== "grabbing") { this.style.cursor = "grabbing"; } }; IgcDataGridComponent.prototype._setBorder = function (borderColor, borderLeft, borderTop, borderRight, borderBottom, radiusTopLeft, radiusTopRight, radiusBottomLeft, radiusBottomRight) { if (this._attached) { if (borderLeft !== 0 || borderTop !== 0 || borderRight !== 0 || borderBottom !== 0) { this.style.borderStyle = "solid"; this.style.borderColor = borderColor; this.style.borderTopWidth = borderTop + "px"; this.style.borderRightWidth = borderRight + "px"; this.style.borderBottomWidth = borderBottom + "px"; this.style.borderLeftWidth = borderLeft + "px"; this.style.borderTopLeftRadius = radiusTopLeft + "px"; this.style.borderTopRightRadius = radiusTopRight + "px"; this.style.borderBottomLeftRadius = radiusBottomLeft + "px"; this.style.borderBottomRightRadius = radiusBottomRight + "px"; } else { this.style.borderStyle = "none"; } } }; IgcDataGridComponent.prototype._setScrollerVerticalTrackInset = function (inset) { this._scroller.verticalTrackStartInset = inset; }; IgcDataGridComponent.prototype.updateContentColumns = function () { this.contentColumns.length = 0; for (var i = 0; i < this.children.length; i++) { if (this.children[i] instanceof IgcDataGridColumnComponent) { this.contentColumns.push(this.children[i]); } } if (this._columnsAdapter != null) { this._columnsAdapter.notifyContentChanged(); } }; IgcDataGridComponent.prototype._insertExternalColumnAtIndex = function (index, column) { //let contentCount = this.contentColumns.length; var contentCount = this._columnsAdapter.actualContent.length; this.columns.insert(index - contentCount, column); }; IgcDataGridComponent.prototype._removeExternalColumn = function (column) { var ind = -1; for (var i = 0; i < this.columns.count; i++) { if (this.columns.item(i) === column) { ind = i; break; } } if (ind >= 0) { this.columns.removeAt(ind); } }; IgcDataGridComponent.prototype.disconnectedCallback = function () { this._disconnected = true; this._attached = false; if (this.i) { if (this._scroller) { this._scroller.onDetachedFromUI(); } if (this._grid.dragger) { this._grid.dragger.onDetachedFromUI(); } if (this._grid.renderingEngine) { this._grid.renderingEngine.detach(); } } }; IgcDataGridComponent.prototype.connectedCallback = function () { if (this._disconnected) { this._disconnected = false; if (this.i) { if (this._scroller) { this._scroller.onAttachedToUI(); } if (this._grid.dragger) { this._grid.dragger.onAttachedToUI(); } } return; } this.classList.add("ig-data-grid"); this.classList.add("igc-data-grid"); this.appendChild(this._contentArea.getNativeElement()); this._attached = true; this.style.display = "block"; this.style.height = this._height; this.style.width = this._width; this.style.boxSizing = "border-box"; this.style.overflow = "hidden"; this.style.display = "flex"; this.style.flexDirection = "column"; this._hasParentAdded = true; if (this.isToolbarVisible) { this.showToolbar(); } if (this._isGroupByAreaVisible == true) { this.SetupColumnGrouping(); } if (this.isPagerVisible) { this.showPager(); } this.i.syncBorder(); this._flushQueuedAttributes(); // supports themes or custom properties set in CSS var prev = this._grid.columnPropertyUpdatingAnimationMode; this._grid.columnPropertyUpdatingAnimationMode = ColumnPropertyUpdatingAnimationMode.None; this._styling(this, this); this._grid.columnPropertyUpdatingAnimationMode = prev; prev = this._grid.columnPropertyUpdatingAnimationMode; this._grid.columnPropertyUpdatingAnimationMode = ColumnPropertyUpdatingAnimationMode.None; for (var i = 0; i < this.actualColumns.count; i++) { var c = this.actualColumns.item(i); c._styling(this, this, this); } this._grid.columnPropertyUpdatingAnimationMode = prev; // moved this content initialization stuff here so we can look for --use-accessibility and --use-canvas custom // css properties. if (!this._initialized) { if (this.useAccessibility) { this._contentLayout = new DataGridAccessibilityLayoutPanel(this._renderer, new DataGridPresenterManager(this._grid, this.useCanvas), window.devicePixelRatio); this._contentLayout.rootElement = this._renderer.rootWrapper; } else { this._contentLayout = new DataGridCellLayoutPanel(this._renderer, new DataGridPresenterManager(this._grid, this.useCanvas), window.devicePixelRatio); } this._grid.renderingEngine = this._contentLayout; this._content = (this._contentLayout.element.getNativeElement()); this._scroller.provideContent(new WebComponentWrapper(this._content, this._renderer)); this._initialized = true; } this.updateContentColumns(); this.afterContentInit(); }; IgcDataGridComponent.prototype.SetupColumnGrouping = function () { if (this._hasColumnGroupingAdded == false && this._hasParentAdded == true) { var groupContainer = this._renderer.createElement("div"); var groupAreaContainer = this._renderer.createElement("div"); groupContainer.append(groupAreaContainer); groupContainer.setStyleProperty("width", "100%"); var groupRenderer = this._renderer.getSubRenderer(groupContainer); this.insertBefore(groupRenderer.rootWrapper.getNativeElement(), this._contentArea.getNativeElement()); //this.appendChild(groupRenderer.rootWrapper.getNativeElement()); var columnGrouping = new ColumnGrouping(); columnGrouping.targetGrid = this._grid; columnGrouping.provideContainer(groupRenderer); this._hasColumnGroupingAdded = true; this.i.columnGrouping = columnGrouping; } }; IgcDataGridComponent.prototype.showPager = function () { if (!this._pager) { this._pager = document.createElement("igc-data-grid-pager"); } if (this._pager && this._hasParentAdded == true) { this._pager.targetGrid = this; this.appendChild(this._pager); this.i.pager = this._pager.i; } }; IgcDataGridComponent.prototype.hidePager = function () { if (this._pager) { this.removeChild(this._pager); this._pager.targetGrid = null; this.i.pager = null; // When the pager is shown it replaces the internal grid's datasource with a new paged one. So when hiding the pager // we need to assign back the original datasource. this._grid.itemsSource = this._dataSource; } }; IgcDataGridComponent.prototype.showToolbar = function () { if (!this._toolbar && this._hasParentAdded == true) { this._toolbar = document.createElement("igc-data-grid-toolbar"); this._toolbar.borderWidthTop = 0; this._toolbar.borderWidthRight = 0; this._toolbar.borderWidthBottom = 1; this._toolbar.borderWidthLeft = 0; this.i.toolbar = this._toolbar.i; this._toolbar.targetGrid = this; } if (this._toolbar && this._hasParentAdded == true) { this.insertBefore(this._toolbar, this._contentArea.getNativeElement()); } }; IgcDataGridComponent.prototype.hideToolbar = function () { if (this._toolbar) { this.removeChild(this._toolbar); } }; Object.defineProperty(IgcDataGridComponent.prototype, "actualDataSource", { get: function () { return this.i.actualDataSource; }, enumerable: false, configurable: true }); IgcDataGridComponent.prototype.afterContentInit = function () { this._grid.itemsSource = this._dataSource; }; IgcDataGridComponent.prototype.refreshContentSize = function () { if (this._content != null) { var width = this._grid.model.absoluteWidth; var height = this._grid.model.absoluteHeight; if (this._scroller != null) { this._scroller.contentWidth = width; this._scroller.contentHeight = height; this._scroller.verticalTrackStartInset = this.getVerticalTrackStartInset(); } } }; IgcDataGridComponent.prototype.onScroll = function () { var top = this._scroller.scrollTop; var left = this._scroller.scrollLeft; var width = this._scroller.viewportWidth; var height = this._scroller.viewportHeight; //console.log("top:" + top); if (this._grid.renderingEngine) { this._grid.setViewport(left, top, left + width, top + height); } }; IgcDataGridComponent.prototype.onScrollStart = function () { this._grid.notifyScrollStart(); }; IgcDataGridComponent.prototype.onScrollStop = function () { this._grid.notifyScrollStop(); }; IgcDataGridComponent.prototype._scrollTo = function (x, y) { this._scroller.scrollTo(x, y); //let width = this._scroller.viewportWidth; //let height = this._scroller.viewportHeight; //this._grid.setViewport(x, y, x + width, y + height); }; Object.defineProperty(IgcDataGridComponent.prototype, "dataSource", { get: function () { return this._dataSource; }, set: function (value) { this._dataSource = value; if (this._grid != null) { this._grid.itemsSource = this._dataSource; } }, enumerable: false, configurable: true }); IgcDataGridComponent.prototype.forColumnsWithPropertyPath = function (propertyPath, callback) { for (var i = 0; i < this.i.actualColumns.count; i++) { var col = this.i.actualColumns.item(i).externalObject; if (col.field == propertyPath) { callback(col); } } }; Object.defineProperty(IgcDataGridComponent.prototype, "defaultColumnWidth", { /** * Gets or sets the default column width to use if a column as no local width. * */ get: function () { var ext = this.i.defaultColumnWidth.externalObject; if (!ext) { ext = new IgcColumnWidth(); ext._implementation = this.i.defaultColumnWidth; } return ext; }, set: function (value) { if (typeof value == "string") { var int = ColumnWidth_internal.parse(value); var ext = new IgcColumnWidth(); ext._implementation = int; value = ext; } this.i.defaultColumnWidth = value.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "insetLeft", { /** * Gets or sets the amount of left inset space to use around the grid content. */ get: function () { return this._insetLeft; }, set: function (v) { this._insetLeft = +v; var inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "insetTop", { /** * Gets or sets the amount of top inset space to use around the grid content. */ get: function () { return this._insetTop; }, set: function (v) { this._insetTop = +v; var inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "insetRight", { /** * Gets or sets the amount of right inset space to use around the grid content. */ get: function () { return this._insetLeft; }, set: function (v) { this._insetRight = +v; var inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "insetBottom", { /** * Gets or sets the amount of bottom inset space to use around the grid content. */ get: function () { return this._insetBottom; }, set: function (v) { this._insetBottom = +v; var inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "isGroupByAreaVisible", { /** * Gets or sets if the Column Grouping Area should be shown and enabled */ get: function () { return this._isGroupByAreaVisible; }, set: function (value) { this._isGroupByAreaVisible = ensureBool(value); this.i.isGroupByAreaVisible = this._isGroupByAreaVisible; if (this._isGroupByAreaVisible == true) { this.SetupColumnGrouping(); } }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "isPagerVisible", { /** * Gets or sets whether to show the pager or not. */ get: function () { return this.i.isPagerVisible; }, set: function (value) { this.i.isPagerVisible = ensureBool(value); if (this.i.isPagerVisible) { this.showPager(); } else { this.hidePager(); } }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "isToolbarVisible", { /** * Gets or sets whether to show the toolbar. */ get: function () { return this.i.isToolbarVisible; }, set: function (value) { this.i.isToolbarVisible = ensureBool(value); if (this.i.isToolbarVisible) { this.showToolbar(); } else { this.hideToolbar(); } }, enumerable: false, configurable: true }); /** * Get the cell that contains the provided coordinates. */ IgcDataGridComponent.prototype.getHitCell = function (x, y) { var cell = this.i.getHitCell(x, y); if (!cell) { return null; } if (!cell.externalObject) { var ext = null; switch (cell.$type.name) { case "DateTimeCellModel": ext = new IgcDateTimeCellInfo(); break; case "ImageCellModel": ext = new IgcImageCellInfo(); break; case "NumericCellModel": ext = new IgcNumericCellInfo(); break; case "RowSeparatorModel": ext = new IgcRowSeparatorInfo(); break; case "SectionHeaderCellModel": ext = new IgcSectionHeaderCellInfo(); break; case "TemplateCellModel": ext = new IgcTemplateCellInfo(); break; case "TemplateHeaderCellModel": ext = new IgcTemplateHeaderCellInfo(); break; case "TemplateSectionHeaderCellModel": ext = new IgcTemplateSectionHeaderCellInfo(); break; case "TextCellModel": ext = new IgcTextCellInfo(); break; case "TextHeaderCellModel": ext = new IgcTextHeaderCellInfo(); break; case "FilterCellModel": ext = new IgcFilterCellInfo(); break; } ext._implementation = cell; cell.externalObject = ext; } return cell.externalObject; }; IgcDataGridComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); }; IgcDataGridComponent.prototype._flushQueuedAttributes = function () { this._settingAttributes = true; for (var i = 0; i < this._queuedSetAttributes.length; i++) { this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue); } this._settingAttributes = false; this._queuedSetAttributes.length = 0; }; IgcDataGridComponent.prototype._a = function (attrName, attrValue) { if (this._updatingFromAttribute) { return; } if (attrValue) { attrValue = attrValue.toString(); } this._settingAttributes = true; attrName = toSpinal(attrName); if (this._attached) { this.setAttribute(attrName, attrValue); } else { this._enqueueSetAttribute(attrName, attrValue); } this._settingAttributes = false; }; Object.defineProperty(IgcDataGridComponent, "observedAttributes", { get: function () { if (IgcDataGridComponent._observedAttributesIgcDataGridComponent == null) { var names = getAllPropertyNames(IgcDataGridComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataGridComponent._observedAttributesIgcDataGridComponent = names; } return IgcDataGridComponent._observedAttributesIgcDataGridComponent; }, enumerable: false, configurable: true }); IgcDataGridComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) { if (this._settingAttributes) { return; } var setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; }; IgcDataGridComponent.register = function () { if (!IgcDataGridComponent._isElementRegistered) { IgcDataGridComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataGridComponent.htmlTagName, IgcDataGridComponent); } }; Object.defineProperty(IgcDataGridComponent.prototype, "columnResizingMode", { /** * Gets or sets the type of column resizing to use. */ get: function () { return this.i.columnResizingMode; }, set: function (v) { this.i.columnResizingMode = ensureEnum(ColumnResizingMode_$type, v); this._a("columnResizingMode", enumToString(ColumnResizingMode_$type, this.i.columnResizingMode)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "columnMovingMode", { /** * Gets or sets the type column moving to use. */ get: function () { return this.i.columnMovingMode; }, set: function (v) { this.i.columnMovingMode = ensureEnum(ColumnMovingMode_$type, v); this._a("columnMovingMode", enumToString(ColumnMovingMode_$type, this.i.columnMovingMode)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "isRowHoverEnabled", { /** * Gets or sets whether the row will highlight when hovered. */ get: function () { return this.i.isRowHoverEnabled; }, set: function (v) { this.i.isRowHoverEnabled = ensureBool(v); this._a("isRowHoverEnabled", this.i.isRowHoverEnabled); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "rowHoverBackground", { /** * Gets or sets the background color for rows when hovered. */ get: function () { return brushToString(this.i.rowHoverBackground); }, set: function (v) { this.i.rowHoverBackground = stringToBrush(v); this._a("rowHoverBackground", brushToString(this.i.rowHoverBackground)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "rowHoverTextColor", { /** * Gets or sets the text color for rows when hovered. */ get: function () { return brushToString(this.i.rowHoverTextColor); }, set: function (v) { this.i.rowHoverTextColor = stringToBrush(v); this._a("rowHoverTextColor", brushToString(this.i.rowHoverTextColor)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "editRowBorder", { /** * Gets or sets the border color for rows being edited. */ get: function () { return brushToString(this.i.editRowBorder); }, set: function (v) { this.i.editRowBorder = stringToBrush(v); this._a("editRowBorder", brushToString(this.i.editRowBorder)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataGridComponent.prototype, "editRowBorderWidthBottom", { get: function () {