/// <summary> /// Ensure that indent and expander, row header columns does not merge. /// </summary> /// <param name="column"></param> /// <returns></returns> internal bool CanQueryColumn(DataColumnBase column) { if (column.Renderer != null && column.Renderer != this.dataGrid.CellRenderers["RowHeader"] && !column.IsIndentColumn && !column.IsExpanderColumn) { return(true); } return(false); }
public override void OnInitializeEditElement(DataColumnBase dataColumn, GridRowHeaderCell uiElement, object dataContext) { RowColumnIndex rowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); if (uiElement is GridRowHeaderCell) { (uiElement as GridRowHeaderCell).RowIndex = rowColumnIndex.RowIndex; } }
protected override void InitializeCellStyle(DataColumnBase dataColumn, object record) { var cell = dataColumn.ColumnElement; var cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); var element = cell as GridRowHeaderCell; if (element != null) { element.RowIndex = cellRowColumnIndex.RowIndex; } base.InitializeCellStyle(dataColumn, record); }
/// <summary> /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.Grid.GridDetailsViewExpanderCell"/> class. /// </summary> /// <param name="isDisposing">Indicates whether the call is from Dispose method or from a finalizer.</param> protected virtual void Dispose(bool isDisposing) { if (isdisposed) { return; } if (isDisposing) { DataGrid = null; columnBase = null; } isdisposed = true; }
private bool CheckAvailablity(int index, bool forIndentColumn) { if (index >= this.DataGrid.VisualContainer.ColumnCount) { return(false); } if (forIndentColumn && ((index < (this.DataGrid.View != null ? this.DataGrid.View.GroupDescriptions.Count : 0)) || (this.DataGrid.ShowRowHeader && index <= (this.DataGrid.View != null ? this.DataGrid.View.GroupDescriptions.Count : 0)))) { if (index > this.RowLevel && (this.RowType == RowType.CaptionCoveredRow || this.RowType == RowType.SummaryCoveredRow || this.RowType == RowType.TableSummaryCoveredRow)) { return(false); } } var cc = this.CoveredCells.FirstOrDefault(cell => cell.Left == index); DataColumnBase dataColumn = this.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == index); if (dataColumn != null) { if (dataColumn.ColumnVisibility == Visibility.Collapsed) { dataColumn.ColumnVisibility = Visibility.Visible; } dataColumn.IsEnsured = true; var columnElement = dataColumn.ColumnElement as GridCell; if (columnElement != null) { columnElement.GridCellRegion = "NormalCell"; } if (this.RowType != Grid.RowType.CaptionRow && this.RowType != Grid.RowType.SummaryRow && (dataColumn.ColumnElement is GridIndentCell) && dataColumn.IndentColumnType == IndentColumnType.AfterExpander) { dataColumn.ColumnVisibility = Visibility.Collapsed; } return(true); } else if (cc != null && this.DataGrid.Columns.Count > 0) { var dc = CreateColumn(cc, index, cc.RowSpan, cc.Right - cc.Left); dc.IsEnsured = true; this.VisibleColumns.Add(dc); } else if (this.DataGrid.Columns.Count > 0 && this.RowRegion != Grid.RowRegion.Header) { var dc = CreateColumn(null, index, 0, 0); dc.IsEnsured = true; this.VisibleColumns.Add(dc); } return(false); }
private void ResetLastColumnBorderThickness(DataColumnBase column, bool isLast) { if (column != null) { bool isTableSummaryRow = this.RowType == Grid.RowType.TableSummaryRow || this.RowType == Grid.RowType.TableSummaryCoveredRow; if (isLast) { (column.ColumnElement as GridCell).GridCellRegion = "LastColumnCell"; } else { (column.ColumnElement as GridCell).GridCellRegion = "NormalCell"; } } }
protected internal override double GetRowSize(DataColumnBase dataColumn, bool lineNull) { var index = dataColumn.RowIndex; if (lineNull) { DoubleSpan[] CurrentPos = this.DataGrid.VisualContainer.ScrollRows.RangeToRegionPoints(index, index, true); return(CurrentPos[1].Length); } var line = GetRowVisibleLineInfo(index); if (line == null) { return(0); } return(line.Size); }
private void UpdateColumn(DataColumnBase dc, int index) { if (index < 0 || index >= this.DataGrid.VisualContainer.ColumnCount) { dc.ColumnVisibility = Visibility.Collapsed; } else { dc.ColumnIndex = index; var columnElement = dc.ColumnElement as GridCell; if (columnElement != null) { columnElement.GridCellRegion = "NormalCell"; } dc.GridColumn = this.DataGrid.Columns[ResolveToGridColumnIndex(index)]; if (dc.ColumnVisibility == Visibility.Collapsed) { dc.ColumnVisibility = Visibility.Visible; } dc.ColumnElement.ClearValue(FrameworkElement.DataContextProperty); //dc.ColumnElement.DataContext = this.RowData; dc.UpdateBinding(this.RowData); } }
/// <summary> /// Applies the Hidden State VSM if the Column in hidden. /// </summary> /// <param name="column">The column.</param> private void UpdateVisualState(bool isPreviousColumnHidden, bool isNextColumnHidden, DataColumnBase columnBase) { var columnElement = (GridHeaderCellControl)columnBase.ColumnElement; if (isPreviousColumnHidden && isNextColumnHidden) { VisualStateManager.GoToState(columnElement, "HiddenState", true); } else if (isPreviousColumnHidden) { VisualStateManager.GoToState(columnElement, "PreviousColumnHidden", true); } else if (isNextColumnHidden) { VisualStateManager.GoToState(columnElement, "LastColumnHidden", true); } else { VisualStateManager.GoToState(columnElement, "NormalState", true); } }
protected override void OnRenderCell(System.Windows.Media.DrawingContext dc, Rect cellRect, DataColumnBase dataColumnBase, object dataContext) { }
private void SetIndentColumnType(DataColumnBase indentColumn) { var group = this.RowData as Group; if (group == null) { return; } int lastGroupLevel = -1; if (!group.IsExpanded) { bool isLastRow = this.DataGrid.RowGenerator.IsLastRow(group, this.RowIndex, ref lastGroupLevel); bool isLastGroup = this.DataGrid.RowGenerator.IsLastGroup(group); lastGroupLevel += (this.DataGrid.ShowRowHeader ? 1 : 0); if (indentColumn.ColumnIndex == ((this.Level + (this.DataGrid.ShowRowHeader ? 1 : 0)) - 1)) { indentColumn.IndentColumnType = IndentColumnType.InExpanderCollapsed; if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Collapsed) { indentColumn.ColumnVisibility = Visibility.Visible; } } else if (indentColumn.ColumnIndex < (this.Level + (this.DataGrid.ShowRowHeader ? 1 : 0) - 1)) { indentColumn.IndentColumnType = indentColumn.ColumnIndex < lastGroupLevel ? (isLastRow ? IndentColumnType.InLastGroupRow : IndentColumnType.BeforeExpander) : (isLastGroup ? IndentColumnType.InLastGroupRow : IndentColumnType.BeforeExpander); if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Collapsed) { indentColumn.ColumnVisibility = Visibility.Visible; } } else { indentColumn.IndentColumnType = IndentColumnType.AfterExpander; if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Visible) { indentColumn.ColumnVisibility = Visibility.Collapsed; } } } else { if (indentColumn.ColumnIndex == (this.Level + (this.DataGrid.ShowRowHeader ? 1 : 0) - 1)) { indentColumn.IndentColumnType = IndentColumnType.InExpanderExpanded; if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Collapsed) { indentColumn.ColumnVisibility = Visibility.Visible; } } else if (indentColumn.ColumnIndex < (this.Level + (this.DataGrid.ShowRowHeader ? 1 : 0) - 1)) { indentColumn.IndentColumnType = IndentColumnType.BeforeExpander; if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Collapsed) { indentColumn.ColumnVisibility = Visibility.Visible; } } else { indentColumn.IndentColumnType = IndentColumnType.AfterExpander; if (this.RowType == RowType.CaptionCoveredRow && indentColumn.ColumnElement.Visibility == Visibility.Visible) { indentColumn.ColumnVisibility = Visibility.Collapsed; } } } }
/// <summary> /// Gets CoveredCellInfo for the specified DataColumnBase. /// </summary> /// <param name="dc"> /// Specifies the corresponding DataColumnBase get the CoveredCellInfo. /// </param> /// <returns> /// Returns the range based on DataColumnBase row and column index. /// </returns> public CoveredCellInfo GetCoveredCellInfo(DataColumnBase dc) { return(GetCoveredCellInfo(dc.RowIndex, dc.ColumnIndex)); }
/// <summary> /// Raise query for the each column /// </summary> /// <param name="dataGrid"></param> /// <param name="dc"></param> internal void EnsureMergedCells(DataRowBase dr, DataColumnBase dc, object dataContext) { if (dc.GridColumn == null) { return; } var coveredCell = dataGrid.CoveredCells.GetCoveredCell(dc.RowIndex, dc.ColumnIndex, dc.GridColumn, dataContext); if (coveredCell == null) { return; } //Throws exception for invalid range with rows. this.dataGrid.CoveredCells.ContainsRow(coveredCell); // Throws exception for invalid range with columns. this.dataGrid.CoveredCells.ContainsColumn(dr, coveredCell); if (!dc.GridColumn.hasCellTemplate && (dc.GridColumn.hasCellTemplateSelector || (dc.GridColumn.IsTemplate && ((dc.GridColumn as GridTemplateColumn).hasEditTemplateSelector || dataGrid.hasCellTemplateSelector)))) // Column has cell template selector will not get merge. { this.dataGrid.CoveredCells.Remove(coveredCell); return; } // Raise exception for the invalid range of unbound row. if (dr.RowType == RowType.UnBoundRow) { var bottomIndex = coveredCell.Bottom; var topIndex = coveredCell.Top; RowRegion topRowRegion = dr.RowRegion; if (dataGrid.RowGenerator.Items.Find(row => row.RowIndex == topIndex) != null) { topRowRegion = dataGrid.RowGenerator.Items.Find(row => row.RowIndex == topIndex).RowRegion; } RowRegion bottomRowRegion = dr.RowRegion; if (dataGrid.RowGenerator.Items.Find(row => row.RowIndex == bottomIndex) != null) { bottomRowRegion = dataGrid.RowGenerator.Items.Find(row => row.RowIndex == bottomIndex).RowRegion; } if (!dataGrid.IsUnBoundRow(bottomIndex) || !dataGrid.IsUnBoundRow(topIndex) || topRowRegion != bottomRowRegion) { throw new Exception(string.Format("Given range {0} is not valid", coveredCell)); } } dr.isSpannedRow = true; dc.isSpannedColumn = true; // Reset the covered cell range by bottom for Frozen rows. if (dataGrid.FrozenRowsCount > 0 && coveredCell.Top < dataGrid.VisualContainer.FrozenRows) { CoveredCellInfo newCoveredCell = null; dataGrid.CoveredCells.Remove(coveredCell); if (coveredCell.Top < dataGrid.VisualContainer.FrozenRows && coveredCell.Bottom >= dataGrid.VisualContainer.FrozenRows) { newCoveredCell = new CoveredCellInfo(coveredCell.Left, coveredCell.Right, coveredCell.Top, coveredCell.Bottom < dataGrid.VisualContainer.FrozenRows ? coveredCell.Bottom : dataGrid.VisualContainer.FrozenRows - 1); } else { newCoveredCell = coveredCell; } dataGrid.CoveredCells.Add(newCoveredCell); this.UpdateMappedRowIndex(dr, dr.RowIndex); dataGrid.RowGenerator.Items.ForEach(row => { if (newCoveredCell != null && row.RowIndex > newCoveredCell.Bottom && row.RowIndex <= coveredCell.Bottom) { dataGrid.MergedCellManager.ResetCoveredRows(row); } } ); } // Reset the covered cell range by top for footer rows. else if (dataGrid.FooterRowsCount > 0 && coveredCell.Bottom >= (this.dataGrid.VisualContainer.RowCount - this.dataGrid.VisualContainer.FooterRows) && coveredCell.Bottom < this.dataGrid.VisualContainer.RowCount) { CoveredCellInfo newCoveredCell = null; dataGrid.CoveredCells.Remove(coveredCell); if (coveredCell.Top < (dataGrid.VisualContainer.RowCount - dataGrid.VisualContainer.FooterRows)) { newCoveredCell = new CoveredCellInfo(coveredCell.Left, coveredCell.Right, coveredCell.Top < (dataGrid.VisualContainer.RowCount - dataGrid.VisualContainer.FooterRows) ? (dataGrid.VisualContainer.RowCount - dataGrid.VisualContainer.FooterRows) : coveredCell.Top, coveredCell.Bottom); } else { newCoveredCell = coveredCell; } dataGrid.CoveredCells.Add(newCoveredCell); this.UpdateMappedRowIndex(dr, dr.RowIndex); dataGrid.RowGenerator.Items.ForEach(row => { if (newCoveredCell != null && row.RowIndex < newCoveredCell.Top && row.RowIndex >= coveredCell.Top) { dataGrid.MergedCellManager.ResetCoveredRows(row); } } ); } // Reset the covered cell range by right for frozen columns if (dataGrid.FrozenColumnCount > 0 && dc.ColumnIndex < dataGrid.VisualContainer.FrozenColumns) { CoveredCellInfo newCoveredCell = null; dataGrid.CoveredCells.Remove(coveredCell); if (coveredCell.Left < dataGrid.VisualContainer.FrozenColumns && coveredCell.Right >= dataGrid.VisualContainer.FrozenColumns) { newCoveredCell = new CoveredCellInfo(coveredCell.Left, coveredCell.Right < dataGrid.VisualContainer.FrozenColumns ? coveredCell.Right : dataGrid.VisualContainer.FrozenColumns - 1, coveredCell.Top, coveredCell.Bottom); } else { newCoveredCell = coveredCell; } dataGrid.CoveredCells.Add(newCoveredCell); this.UpdateMappedRowIndex(dr, dr.RowIndex); dataGrid.RowGenerator.Items.ForEach(row => { if (newCoveredCell != null && row.RowIndex >= coveredCell.Top && row.RowIndex <= coveredCell.Bottom) { row.VisibleColumns.ForEach(column => { if (column.ColumnIndex > newCoveredCell.Right && column.ColumnIndex <= coveredCell.Right) { column.isSpannedColumn = false; column.ColumnVisibility = Visibility.Visible; } }); } } ); } // Reset the covered cell range by left for frozen columns else if (dataGrid.FooterColumnCount > 0 && coveredCell.Right >= (dataGrid.VisualContainer.ColumnCount - dataGrid.VisualContainer.FooterColumns) && coveredCell.Right < dataGrid.VisualContainer.ColumnCount) { CoveredCellInfo newCoveredCell = null; dataGrid.CoveredCells.Remove(coveredCell); if ((dataGrid.VisualContainer.ColumnCount - dataGrid.VisualContainer.FooterColumns) >= coveredCell.Left && coveredCell.Right <= dataGrid.VisualContainer.ColumnCount) { newCoveredCell = new CoveredCellInfo(coveredCell.Left, coveredCell.Right < (dataGrid.VisualContainer.ColumnCount - dataGrid.VisualContainer.FooterColumns) ? coveredCell.Right : dataGrid.VisualContainer.ColumnCount - dataGrid.VisualContainer.FooterColumns, coveredCell.Top, coveredCell.Bottom); } else { newCoveredCell = coveredCell; } dataGrid.CoveredCells.Add(newCoveredCell); this.UpdateMappedRowIndex(dr, dr.RowIndex); dataGrid.RowGenerator.Items.ForEach(row => { if (newCoveredCell != null && row.RowIndex >= coveredCell.Top && row.RowIndex <= coveredCell.Bottom) { row.VisibleColumns.ForEach(column => { if (column.ColumnIndex > newCoveredCell.Right && column.ColumnIndex <= coveredCell.Right) { column.isSpannedColumn = false; column.ColumnVisibility = Visibility.Visible; } }); } } ); } }
public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridRowHeaderCell element, object dataContext) { }
/// <summary> /// Updates the Cell border state for footer columns and before footer columns. /// </summary> /// <param name="dc"></param> internal override void UpdateFixedColumnState(DataColumnBase dc) { if (this.DataGrid.VisualContainer.FooterColumns == 0 || dc.ColumnIndex <= this.DataGrid.VisualContainer.FrozenColumns - 1) { //When footer column is set to zero then all the cells would be normal cell. if (this.RowType != Grid.RowType.HeaderRow) { if (dc.ColumnIndex == this.DataGrid.VisualContainer.FrozenColumns - 1) { dc.OnGridCellRegionChanged(GridCellRegion.FrozenColumnCell); } else { dc.OnGridCellRegionChanged(GridCellRegion.NormalCell); } } else { if (dc.ColumnIndex == this.DataGrid.VisualContainer.FrozenColumns - 1) { (dc.ColumnElement as GridHeaderCellControl).GridCellRegion = GridCellRegion.FrozenColumnCell; } else { (dc.ColumnElement as GridHeaderCellControl).GridCellRegion = GridCellRegion.NormalCell; } } return; } var columnCount = this.DataGrid.VisualContainer.ColumnCount; int previousColumnIndex = this.GetPreviousColumnIndex(columnCount - this.DataGrid.FooterColumnCount); //lastCellIndex is used to draw right border for the last body column when all the footer columns are hidden. var lastCellIndex = this.DataGrid.GetLastColumnIndex(); //isFooterColumnHidden is used to draw the right border for previous of last body column when the last body column is in hidden. bool isFooterColumnHidden = false; if (dc.ColumnIndex > columnCount - this.DataGrid.FooterColumnCount) { isFooterColumnHidden = GetPreviousColumnIndex(dc.ColumnIndex) < columnCount - this.DataGrid.FooterColumnCount; } if (this.RowType != Grid.RowType.HeaderRow) { if (dc.ColumnIndex == previousColumnIndex && dc.ColumnIndex != lastCellIndex) { dc.OnGridCellRegionChanged(GridCellRegion.BeforeFooterColumnCell); } else if (dc.ColumnIndex == columnCount - this.DataGrid.FooterColumnCount || isFooterColumnHidden) { dc.OnGridCellRegionChanged(GridCellRegion.FooterColumnCell); } else { dc.OnGridCellRegionChanged(GridCellRegion.NormalCell); } if (this.IsSpannedRow) { var coveredCellInfo = this.DataGrid.CoveredCells.GetCoveredCellInfo(dc); if (coveredCellInfo != null && previousColumnIndex == coveredCellInfo.Right) { dc.OnGridCellRegionChanged(GridCellRegion.BeforeFooterColumnCell); } } } else if (dc.ColumnElement is GridHeaderCellControl) { if (dc.ColumnIndex == columnCount - this.DataGrid.FooterColumnCount || isFooterColumnHidden) { (dc.ColumnElement as GridHeaderCellControl).GridCellRegion = GridCellRegion.FooterColumnCell; } else if (dc.ColumnIndex == previousColumnIndex && dc.ColumnIndex != lastCellIndex) { (dc.ColumnElement as GridHeaderCellControl).GridCellRegion = GridCellRegion.BeforeFooterColumnCell; } else { (dc.ColumnElement as GridHeaderCellControl).GridCellRegion = GridCellRegion.NormalCell; } } }
protected override void CollapseColumn(DataColumnBase column) { base.CollapseColumn(column); }
internal abstract void UpdateFixedColumnState(DataColumnBase dc);
protected internal virtual double GetRowSize(DataColumnBase dataColumn, bool lineNull) { return(0); }
protected virtual void CollapseColumn(DataColumnBase column) { column.IsEnsured = true; column.ColumnVisibility = Visibility.Collapsed; }