//The cell style settings can be customized void TableModel_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if (allowTooltip && e.RowIndex > 0 && e.ColIndex > 0 && e.RowIndex <= pivotGridControl1.PivotEngine.RowCount) { PivotCellInfo cellinfo = pivotGridControl1.PivotEngine[e.RowIndex - 1, e.ColIndex - 1]; string tooltip = "Value\t: " + (string.IsNullOrEmpty(e.Style.Text) ? "(No Value)" : e.Style.Text.ToString()); PivotCellInfo colParent = pivotGridControl1.PivotEngine[0, e.ColIndex - 1].ParentCell; PivotCellInfo rowParent = pivotGridControl1.PivotEngine[e.RowIndex - 1, 0].ParentCell; if (colParent != null) { tooltip += "\nColumn\t: " + colParent.Value; } else { if (pivotGridControl1.PivotEngine[0, e.ColIndex - 1].Value != null && pivotGridControl1.PivotEngine[0, e.ColIndex - 1].Value.ToString() != null) { tooltip += "\nColumn\t: " + pivotGridControl1.PivotEngine[0, e.ColIndex - 1].Value; } else if (pivotGridControl1.PivotEngine[0, e.ColIndex - 1].Value == null && e.ColIndex > 1) { tooltip += "\nColumn\t: " + pivotGridControl1.PivotEngine[0, e.ColIndex - 2].Value; } } object subRow = pivotGridControl1.PivotEngine[e.RowIndex - 1, 1].Value; if (rowParent != null) { tooltip += "\nRow\t: " + rowParent.Value + " - " + subRow; } else { tooltip += "\nRow\t: " + (pivotGridControl1.PivotEngine[e.RowIndex - 1, 0].Value != null ? pivotGridControl1.PivotEngine[e.RowIndex - 1, 0].Value : pivotGridControl1.PivotEngine[e.RowIndex - 1, 0].UniqueText) + " - " + subRow; } if (e.Style.Tag != null) { string valueHeader = cellinfo.CellType.ToString().Contains("ColumnHeaderCell") ? "Column : " : (cellinfo.CellType.ToString().Contains("RowHeaderCell") ? "Row : " : "Value : "); tooltip = valueHeader + e.Style.Text; } if ((!chkColHeader.Checked && (cellinfo.CellType == (PivotCellType.ColumnHeaderCell | PivotCellType.ExpanderCell) || cellinfo.CellType == (PivotCellType.ColumnHeaderCell | PivotCellType.HeaderCell) || cellinfo.CellType == (PivotCellType.ColumnHeaderCell | PivotCellType.CalculationHeaderCell))) || (!chkRowHeader.Checked && (cellinfo.CellType == (PivotCellType.RowHeaderCell | PivotCellType.ExpanderCell) || cellinfo.CellType == (PivotCellType.RowHeaderCell | PivotCellType.HeaderCell))) || (!chkSummary.Checked && (cellinfo.CellType == (PivotCellType.GrandTotalCell | PivotCellType.ValueCell) || cellinfo.CellType == (PivotCellType.TotalCell | PivotCellType.ValueCell))) || (!chkValue.Checked && cellinfo.CellType == PivotCellType.ValueCell) || (!chkSumHeader.Checked && (cellinfo.CellType == (PivotCellType.GrandTotalCell | PivotCellType.RowHeaderCell) || cellinfo.CellType == (PivotCellType.GrandTotalCell | PivotCellType.ColumnHeaderCell) || cellinfo.CellType == (PivotCellType.GrandTotalCell | PivotCellType.ColumnHeaderCell | PivotCellType.HeaderCell) || cellinfo.CellType == (PivotCellType.GrandTotalCell | PivotCellType.RowHeaderCell | PivotCellType.HeaderCell) || cellinfo.CellType == (PivotCellType.TotalCell | PivotCellType.RowHeaderCell) || cellinfo.CellType == (PivotCellType.TotalCell | PivotCellType.ColumnHeaderCell)))) { tooltip = string.Empty; } e.Style.CellTipText = tooltip; } }
/// <summary> /// This event handler method is hooked when the particular cell was clicked. /// </summary> /// <param name="sender">The current cell.</param> /// <param name="args">The event argument.</param> private void InternalGrid_CellClick(object sender, Syncfusion.UI.Xaml.CellGrid.Helpers.GridCellClickEventArgs args) { txtBox.Text = ""; lstSelectedItems.ItemsSource = null; PivotCellInfo cellInfo = pivotGrid1.PivotEngine[args.RowIndex, args.ColumnIndex]; if (cellInfo.CellType.ToString().Contains("ValueCell")) { var itemSource = pivotGrid1.PivotEngine.GetRawItemsFor(args.RowIndex, args.ColumnIndex); txtBox.Text = itemSource.Count.ToString(); lstSelectedItems.ItemsSource = itemSource; } }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { PivotCellInfo cellInfo = value as PivotCellInfo; if (cellInfo != null) { if (cellInfo.CellType.ToString().Contains(PivotCellType.ExpanderCell.ToString()) || cellInfo.Tag != null) { return(Visibility.Visible); } return(Visibility.Hidden); } return(Visibility.Hidden); }
protected override void ChangeValue(object oldValue, object newValue, int row1, int col1, PivotCellInfo pi) { //do the base change base.ChangeValue(oldValue, newValue, row1, col1, pi); //mark all the adjusted cell contents pi.FormattedText += "*"; }