UNPKG

igniteui-webcomponents-grids

Version:

Ignite UI Web Components grid components.

1,053 lines 189 kB
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"; let GridStylingDefaults = {}; export let IgcDataGridComponent = /*@__PURE__*/ (() => { class IgcDataGridComponent extends IgcHTMLElement { _ensureColumnsAreManual() { this._disableManualColumnSync = true; this._columnsAdapter.shiftContentToManual(this.columns, (i) => i.isFromMarkup = false); this._disableManualColumnSync = false; } /** * A collection or manually added columns for the grid. */ get columns() { if (this._columns === null) { let coll = new IgcGridColumnCollection(); let inner = coll._innerColl; inner.addListener((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; } set height(value) { this._height = value; this.style.height = value; this.containerResized(); } get height() { return this._height; } set width(value) { this._width = value; this.style.width = value; this.containerResized(); } get width() { return this._width; } set useCanvas(value) { this._useCanvas = ensureBool(value); } get useCanvas() { return this._useCanvas; } set useAccessibility(value) { this._useAccessibility = ensureBool(value); } get useAccessibility() { return this._useAccessibility; } _setScrollbarStyle(style) { if (this._scroller) { this._scroller.scrollbarStyle = style; } } _setScrollbarColor(color) { if (this._scroller) { this._scroller.scrollbarBrush = color; } } createImplementation() { //let test = Grid; return new DataGrid(); } get i() { return this._implementation; } onImplementationCreated() { } constructor() { super(); 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, (c) => c.i, (i) => { i._provideRenderer(this._wrapper); if (this.parentElement) { i._styling(this, this, this); } }, (i) => { i._provideRenderer(null); }, (i) => { return i.name || i.field; }); grid.externalGrid = new GridExternalWrapper(this); grid.tickProvider = new BrowserTickProvider(this._renderer); grid.platformPixelConverter = new BrowserPixelConverter(); let 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); let 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 = () => this.onScroll(); scroller.onScrollStart = () => this.onScrollStart(); scroller.onScrollStop = () => 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; let mut = new MutationObserver((list) => { for (var mutation of list) { if (mutation.type == 'childList') { this.updateContentColumns(); } } }); mut.observe(this, { childList: true }); this._renderer.addSizeWatcher(() => { this.containerResized(); }); } getVerticalTrackStartInset() { var isFilterRowEnabled = this.filterUIType === FilterUIType.FilterRow; var filterRowHeight = isFilterRowEnabled ? this.actualRowHeight + this.rowSeparatorHeight : 0; return this.actualHeaderHeight + this.rowSeparatorHeight + filterRowHeight; } _focusScroller() { this._scroller.focus(); } _setDefaultCursor() { if (this.style.cursor !== "") { this.style.cursor = ""; } } _setResizeCursor() { if (this.style.cursor !== "col-resize") { this.style.cursor = "col-resize"; } } _setHandCursor() { if (this.style.cursor !== "grabbing") { this.style.cursor = "grabbing"; } } _setBorder(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"; } } } _setScrollerVerticalTrackInset(inset) { this._scroller.verticalTrackStartInset = inset; } updateContentColumns() { 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(); } } _insertExternalColumnAtIndex(index, column) { //let contentCount = this.contentColumns.length; let contentCount = this._columnsAdapter.actualContent.length; this.columns.insert(index - contentCount, column); } _removeExternalColumn(column) { let ind = -1; for (let i = 0; i < this.columns.count; i++) { if (this.columns.item(i) === column) { ind = i; break; } } if (ind >= 0) { this.columns.removeAt(ind); } } disconnectedCallback() { 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(); } } } connectedCallback() { 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 let 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 (let i = 0; i < this.actualColumns.count; i++) { let 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(); } SetupColumnGrouping() { 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()); let columnGrouping = new ColumnGrouping(); columnGrouping.targetGrid = this._grid; columnGrouping.provideContainer(groupRenderer); this._hasColumnGroupingAdded = true; this.i.columnGrouping = columnGrouping; } } showPager() { 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; } } hidePager() { 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; } } showToolbar() { 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()); } } hideToolbar() { if (this._toolbar) { this.removeChild(this._toolbar); } } get actualDataSource() { return this.i.actualDataSource; } afterContentInit() { this._grid.itemsSource = this._dataSource; } refreshContentSize() { 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(); } } } onScroll() { let top = this._scroller.scrollTop; let left = this._scroller.scrollLeft; let width = this._scroller.viewportWidth; let height = this._scroller.viewportHeight; //console.log("top:" + top); if (this._grid.renderingEngine) { this._grid.setViewport(left, top, left + width, top + height); } } onScrollStart() { this._grid.notifyScrollStart(); } onScrollStop() { this._grid.notifyScrollStop(); } _scrollTo(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); } set dataSource(value) { this._dataSource = value; if (this._grid != null) { this._grid.itemsSource = this._dataSource; } } get dataSource() { return this._dataSource; } forColumnsWithPropertyPath(propertyPath, callback) { for (let i = 0; i < this.i.actualColumns.count; i++) { let col = this.i.actualColumns.item(i).externalObject; if (col.field == propertyPath) { callback(col); } } } /** * Gets or sets the default column width to use if a column as no local width. * */ get defaultColumnWidth() { let ext = this.i.defaultColumnWidth.externalObject; if (!ext) { ext = new IgcColumnWidth(); ext._implementation = this.i.defaultColumnWidth; } return ext; } set defaultColumnWidth(value) { if (typeof value == "string") { let int = ColumnWidth_internal.parse(value); let ext = new IgcColumnWidth(); ext._implementation = int; value = ext; } this.i.defaultColumnWidth = value.i; } /** * Gets or sets the amount of left inset space to use around the grid content. */ get insetLeft() { return this._insetLeft; } set insetLeft(v) { this._insetLeft = +v; let inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; } /** * Gets or sets the amount of top inset space to use around the grid content. */ get insetTop() { return this._insetTop; } set insetTop(v) { this._insetTop = +v; let inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; } /** * Gets or sets the amount of right inset space to use around the grid content. */ get insetRight() { return this._insetLeft; } set insetRight(v) { this._insetRight = +v; let inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; } /** * Gets or sets the amount of bottom inset space to use around the grid content. */ get insetBottom() { return this._insetBottom; } set insetBottom(v) { this._insetBottom = +v; let inset = new Thickness(1, this._insetLeft, this._insetTop, this._insetRight, this._insetBottom); this.i.inset = inset; } /** * Gets or sets if the Column Grouping Area should be shown and enabled */ get isGroupByAreaVisible() { return this._isGroupByAreaVisible; } set isGroupByAreaVisible(value) { this._isGroupByAreaVisible = ensureBool(value); this.i.isGroupByAreaVisible = this._isGroupByAreaVisible; if (this._isGroupByAreaVisible == true) { this.SetupColumnGrouping(); } } /** * Gets or sets whether to show the pager or not. */ get isPagerVisible() { return this.i.isPagerVisible; } set isPagerVisible(value) { this.i.isPagerVisible = ensureBool(value); if (this.i.isPagerVisible) { this.showPager(); } else { this.hidePager(); } } /** * Gets or sets whether to show the toolbar. */ get isToolbarVisible() { return this.i.isToolbarVisible; } set isToolbarVisible(value) { this.i.isToolbarVisible = ensureBool(value); if (this.i.isToolbarVisible) { this.showToolbar(); } else { this.hideToolbar(); } } /** * Get the cell that contains the provided coordinates. */ getHitCell(x, y) { let cell = this.i.getHitCell(x, y); if (!cell) { return null; } if (!cell.externalObject) { let 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; } _enqueueSetAttribute(attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); } _flushQueuedAttributes() { this._settingAttributes = true; for (let i = 0; i < this._queuedSetAttributes.length; i++) { this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue); } this._settingAttributes = false; this._queuedSetAttributes.length = 0; } _a(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; } static get observedAttributes() { if (IgcDataGridComponent._observedAttributesIgcDataGridComponent == null) { let names = getAllPropertyNames(IgcDataGridComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataGridComponent._observedAttributesIgcDataGridComponent = names; } return IgcDataGridComponent._observedAttributesIgcDataGridComponent; } attributeChangedCallback(name, oldValue, newValue) { if (this._settingAttributes) { return; } let setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; } static register() { if (!IgcDataGridComponent._isElementRegistered) { IgcDataGridComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataGridComponent.htmlTagName, IgcDataGridComponent); } } /** * Gets or sets the type of column resizing to use. */ get columnResizingMode() { return this.i.columnResizingMode; } set columnResizingMode(v) { this.i.columnResizingMode = ensureEnum(ColumnResizingMode_$type, v); this._a("columnResizingMode", enumToString(ColumnResizingMode_$type, this.i.columnResizingMode)); } /** * Gets or sets the type column moving to use. */ get columnMovingMode() { return this.i.columnMovingMode; } set columnMovingMode(v) { this.i.columnMovingMode = ensureEnum(ColumnMovingMode_$type, v); this._a("columnMovingMode", enumToString(ColumnMovingMode_$type, this.i.columnMovingMode)); } /** * Gets or sets whether the row will highlight when hovered. */ get isRowHoverEnabled() { return this.i.isRowHoverEnabled; } set isRowHoverEnabled(v) { this.i.isRowHoverEnabled = ensureBool(v); this._a("isRowHoverEnabled", this.i.isRowHoverEnabled); } /** * Gets or sets the background color for rows when hovered. */ get rowHoverBackground() { return brushToString(this.i.rowHoverBackground); } set rowHoverBackground(v) { this.i.rowHoverBackground = stringToBrush(v); this._a("rowHoverBackground", brushToString(this.i.rowHoverBackground)); } /** * Gets or sets the text color for rows when hovered. */ get rowHoverTextColor() { return brushToString(this.i.rowHoverTextColor); } set rowHoverTextColor(v) { this.i.rowHoverTextColor = stringToBrush(v); this._a("rowHoverTextColor", brushToString(this.i.rowHoverTextColor)); } /** * Gets or sets the border color for rows being edited. */ get editRowBorder() { return brushToString(this.i.editRowBorder); } set editRowBorder(v) { this.i.editRowBorder = stringToBrush(v); this._a("editRowBorder", brushToString(this.i.editRowBorder)); } get editRowBorderWidthBottom() { return this.i.editRowBorderWidth ? this.i.editRowBorderWidth.bottom : NaN; } set editRowBorderWidthBottom(v) { this.ensureEditRowBorderWidth(); this.i.editRowBorderWidth.bottom = +v; this._a("editRowBorderWidthBottom", this.i.editRowBorderWidth.bottom); this.i.editRowBorderWidth = this.i.editRowBorderWidth; } get editRowBorderWidthLeft() { return this.i.editRowBorderWidth ? this.i.editRowBorderWidth.left : NaN; } set editRowBorderWidthLeft(v) { this.ensureEditRowBorderWidth(); this.i.editRowBorderWidth.left = +v; this._a("editRowBorderWidthLeft", this.i.editRowBorderWidth.left); this.i.editRowBorderWidth = this.i.editRowBorderWidth; } get editRowBorderWidthRight() { return this.i.editRowBorderWidth ? this.i.editRowBorderWidth.right : NaN; } set editRowBorderWidthRight(v) { this.ensureEditRowBorderWidth(); this.i.editRowBorderWidth.right = +v; this._a("editRowBorderWidthRight", this.i.editRowBorderWidth.right); this.i.editRowBorderWidth = this.i.editRowBorderWidth; } get editRowBorderWidthTop() { return this.i.editRowBorderWidth ? this.i.editRowBorderWidth.top : NaN; } set editRowBorderWidthTop(v) { this.ensureEditRowBorderWidth(); this.i.editRowBorderWidth.top = +v; this._a("editRowBorderWidthTop", this.i.editRowBorderWidth.top); this.i.editRowBorderWidth = this.i.editRowBorderWidth; } ensureEditRowBorderWidth() { if (this.i.editRowBorderWidth) { return; } this.i.editRowBorderWidth = new Thickness(2); } /** * Gets or sets the header type used for sectioning off groups of rows. */ get sectionHeader() { const r = this.i.sectionHeader; if (r == null) { return null; } if (!r.externalObject) { let e = IgcSectionHeaderComponent._createFromInternal(r); if (e) { e._implementation = r; } r.externalObject = e; } return r.externalObject; } set sectionHeader(v) { if (v != null && this._stylingContainer && v._styling) v._styling(this._stylingContainer, this, this); v == null ? this.i.sectionHeader = null : this.i.sectionHeader = v.i; } /** * Gets or sets the cell definition used for summary rows at the root level. */ get summaryRowRoot() { const r = this.i.summaryRowRoot; if (r == null) { return null; } if (!r.externalObject) { let e = IgcSummaryRowRootComponent._createFromInternal(r); if (e) { e._implementation = r; } r.externalObject = e; } return r.externalObject; } set summaryRowRoot(v) { if (v != null && this._stylingContainer && v._styling) v._styling(this._stylingContainer, this, this); v == null ? this.i.summaryRowR