Category / Section
How can we access CellSet before sending it to the OlapGrid?
1 min read
You can access the CellSet before sending it to the OlapGrid through the CellSetChanged event of the OlapDataManager class. The CellSet that you access through the CellSetChanged event is Syncfusion’s CellSet not Microsoft’s.
C#
public MainWindow() { try { InitializeComponent(); this.olapgrid.OlapDataManager = new Syncfusion.Olap.Manager.OlapDataManager("Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;"); this.olapgrid.OlapDataManager.SetCurrentReport(SampleReport()); (this.olapgrid.OlapDataManager as OlapDataManager).CellSetChanged += MainWindow_CellSetChanged; } catch (Exception ex) { MessageBox.Show(ex.Message, "Data will not be loaded properly"); } } void MainWindow_CellSetChanged(object sender, CellSetChangedEventArgs e) { Syncfusion.Olap.Data.CellSet cellset = e.NewCellSet; } private OlapReport SampleReport() { OlapReport olapReport = new OlapReport(); olapReport.CurrentCubeName = "Adventure Works"; DimensionElement dimensionElementColumn = new DimensionElement(); dimensionElementColumn.Name = "Customer"; dimensionElementColumn.HierarchyName = "Customer Geography"; dimensionElementColumn.AddLevel("Customer Geography", "Country"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); olapReport.CategoricalElements.Add(new Item { ElementValue = dimensionElementColumn }); olapReport.CategoricalElements.Add(new Item { ElementValue = measureElementColumn }); olapReport.SeriesElements.Add(new Item { ElementValue = dimensionElementRow }); return olapReport; }
VB
Public Sub New() Try InitializeComponent() Me.olapgrid.OlapDataManager = New Syncfusion.Olap.Manager.OlapDataManager("Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;") Me.olapgrid.OlapDataManager.SetCurrentReport(SampleReport()) AddHandler TryCast(Me.olapgrid.OlapDataManager, OlapDataManager).CellSetChanged, AddressOf MainWindow_CellSetChanged Catch ex As Exception MessageBox.Show(ex.Message, "Data will not be loaded properly") End Try End Sub Private Sub MainWindow_CellSetChanged(ByVal sender As Object, ByVal e As CellSetChangedEventArgs) Dim cellset As Syncfusion.Olap.Data.CellSet = e.NewCellSet End Sub Private Function SampleReport() As OlapReport Dim olapReport As New OlapReport() olapReport.CurrentCubeName = "Adventure Works" Dim dimensionElementColumn As New DimensionElement() dimensionElementColumn.Name = "Customer" dimensionElementColumn.HierarchyName = "Customer Geography" dimensionElementColumn.AddLevel("Customer Geography", "Country") Dim measureElementColumn As New MeasureElements() measureElementColumn.Elements.Add(New MeasureElement With {.Name = "Internet Sales Amount"}) Dim dimensionElementRow As New DimensionElement() dimensionElementRow.Name = "Date" dimensionElementRow.AddLevel("Fiscal", "Fiscal Year") olapReport.CategoricalElements.Add(New Item With {.ElementValue = dimensionElementColumn}) olapReport.CategoricalElements.Add(New Item With {.ElementValue = measureElementColumn}) olapReport.SeriesElements.Add(New Item With {.ElementValue = dimensionElementRow}) Return olapReport End Function