For the PivotGridControl implement the CustomCellValue and CustomDrawFieldValue events. In the CustomCellValue correlate your pivot grid data with your other data and set the e.Value property.
In the CustomDrawFieldValue set e.Info.Caption to each of your desired caption properties. Here are the snippets, and I will be writing a blog tomorrow with downloadable code and pictures tomorrow.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
using DevExpress.Data.PivotGrid;
using System.Reflection;
namespace S319857
{
public partial class Form1 : Form
{
private List<Data> datum;
public Form1()
{
InitializeComponent();
datum = new List<Data>{
new Data{ID=1, Cash="100", EftPos="Dummy", HealthFund="H1"},
new Data{ID=2, Cash="200", EftPos="Dummy", HealthFund="H2"},
new Data{ID=3, Cash="300", EftPos="Dummy", HealthFund="H3"},
new Data{ID=4, Cash="400", EftPos="Dummy", HealthFund="H4"},
new Data{ID=5, Cash="500", EftPos="Dummy", HealthFund="H5"},
new Data{ID=6, Cash="600", EftPos="Dummy", HealthFund="H6"},
new Data{ID=7, Cash="700", EftPos="Dummy", HealthFund="H7"},
new Data{ID=8, Cash="800", EftPos="Dummy", HealthFund="H8"}};
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'northwindDataSet.Products' table. You can move, or remove it, as needed.
this.productsTableAdapter.Fill(this.northwindDataSet.Products);
}
private void pivotGridControl1_CustomSummary(object sender, DevExpress.XtraPivotGrid.PivotGridCustomSummaryEventArgs e)
{
}
private void pivotGridControl1_CustomAppearance(object sender, DevExpress.XtraPivotGrid.PivotCustomAppearanceEventArgs e)
{
}
private void pivotGridControl1_CustomCellDisplayText(object sender, DevExpress.XtraPivotGrid.PivotCellDisplayTextEventArgs e)
{
}
private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e)
{
int ID = Convert.ToInt32(e.GetFieldValue(fieldCategoryID1));
Data obj = datum.Find(d => d.ID == ID);
if ((e.SummaryType == PivotSummaryType.Custom) && (e.DataField == fieldUnitPrice1))
{
if (Convert.ToInt32(e.RowCustomTotal.Tag) == 1)
e.Value = obj.Cash;
else if (Convert.ToInt32(e.RowCustomTotal.Tag) == 2)
e.Value = obj.EftPos;
else if (Convert.ToInt32(e.RowCustomTotal.Tag) == 3)
e.Value = obj.HealthFund;
}
}
private void pivotGridControl1_CustomDrawFieldValue(object sender, PivotCustomDrawFieldValueEventArgs e)
{
if (e.Info.Caption.Contains("Custom"))
{
if (Convert.ToInt32(e.CustomTotal.Tag) == 1)
e.Info.Caption = "CASH";
else if (Convert.ToInt32(e.CustomTotal.Tag) == 2)
e.Info.Caption = "EFTPOS";
else if (Convert.ToInt32(e.CustomTotal.Tag) == 3)
e.Info.Caption = "Health Fund";
}
}
}
public class Data
{
private int iD;
public int ID
{
get { return iD; }
set { iD = value; }
}
private string cash;
public string Cash
{
get { return cash; }
set { cash = value; }
}
private string eftPost;
public string EftPos
{
get { return eftPost; }
set { eftPost = value; }
}
private string healthFund;
public string HealthFund
{
get { return healthFund; }
set { healthFund = value; }
}
}
}