private string GetCellDisplayText(object val, PivotGridCellTemplateItem cell) { if (val == null) { return("No Data"); } FormatInfo cellFormat = null; if (cell.DataField.GrandTotalCellFormat.FormatType != DevExpress.Utils.FormatType.None) { cellFormat = cell.DataField.GrandTotalCellFormat; } else if (cell.DataField.CellFormat.FormatType != DevExpress.Utils.FormatType.None) { cellFormat = cell.DataField.CellFormat; } if (cellFormat != null) { if (cellFormat.FormatType == FormatType.DateTime) { return(Convert.ToDateTime(val).ToString(cellFormat.FormatString)); } else { return(Convert.ToDecimal(val).ToString(cellFormat.FormatString)); } } return(val.ToString()); }
private object GetTotalValue(PivotGridCellTemplateItem c, ASPxPivotGrid sourcePivotGrid) { List <PivotGridField> columnFields = pivotGrid.GetFieldsByArea(DevExpress.XtraPivotGrid.PivotArea.ColumnArea); List <PivotGridField> rowFields = pivotGrid.GetFieldsByArea(DevExpress.XtraPivotGrid.PivotArea.RowArea); List <object> rowFieldValues = new List <object>(); List <object> columnFieldValues = new List <object>(); if (c.ColumnField != null) { foreach (PivotGridField field in columnFields) { if (field.AreaIndex > c.ColumnField.AreaIndex) { continue; } object currentValue = c.GetFieldValue(field); if (currentValue != null) { columnFieldValues.Add(currentValue); } } } if (c.RowField != null) { foreach (PivotGridField field in rowFields) { if (field.AreaIndex > c.RowField.AreaIndex) { continue; } object currentValue = c.GetFieldValue(field); if (currentValue != null) { rowFieldValues.Add(currentValue); } } } sourcePivotGrid.EnsureRefreshData(); object res = sourcePivotGrid.Data.GetCellValue(columnFieldValues.ToArray(), rowFieldValues.ToArray(), c.DataField); return(res); }
private bool ShouldDisplaySecondValue(PivotGridCellTemplateItem cell) { if (cell.RowValueType == DevExpress.XtraPivotGrid.PivotGridValueType.GrandTotal) { PivotGridField rowField = pivotGrid.GetFieldByArea(DevExpress.XtraPivotGrid.PivotArea.RowArea, 0); if (rowField != null && rowField.TopValueCount > 0) { return(true); } } if (cell.ColumnValueType == DevExpress.XtraPivotGrid.PivotGridValueType.GrandTotal) { PivotGridField columnField = pivotGrid.GetFieldByArea(DevExpress.XtraPivotGrid.PivotArea.ColumnArea, 0); if (columnField != null && columnField.TopValueCount > 0) { return(true); } } return(false); }
private Control CreateCellTable(PivotGridCellTemplateItem cell) { Dictionary <object, decimal> values = GetSummaryValues(cell.CreateDrillDownDataSource(), sourceField, cell.DataField); Table table = new Table(); foreach (KeyValuePair <object, decimal> pair in values) { TableRow tr = new TableRow(); table.Controls.Add(tr); TableCell tc1 = new TableCell(); tc1.Style.Add(HtmlTextWriterStyle.Padding, "0px"); tc1.Text = pair.Key.ToString(); tr.Controls.Add(tc1); TableCell tc2 = new TableCell(); tc2.Style.Add(HtmlTextWriterStyle.Padding, "0px"); tc2.Text = pair.Value.ToString(); tr.Controls.Add(tc2); } return(table); }