Category / Section
How to rename the caption inside AxisElementBuilder?
1 min read
You can change the name displayed in SplitButton of AxisElementBuilder as illustrated in the following code example.
C#
public MainWindow() { try { InitializeComponent(); this.olapClient1.OlapDataManager = new Syncfusion.Olap.Manager.OlapDataManager("Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;"); this.olapClient1.OlapDataManager.SetCurrentReport(SampleReport()); this.olapClient1.OlapDataManager.AxisElementChanged += new Syncfusion.Olap.Manager.AxisElementChangedEventHandler(OlapDataManager_AxisElementChanged); } catch (Exception ex) { MessageBox.Show(ex.Message, "Data will not be loaded properly"); } } void OlapDataManager_AxisElementChanged(object sender, AxisElementChangedEventArgs e) { foreach (MetaTreeNode node in olapClient1.AxisElementBuilderRow.MetaTreeNodes) { var hierarchy = node.Properties.FindByName(PropertyConstants.Hierarchy); var dimension = node.Properties.FindByName(PropertyConstants.Dimension); if (dimension != null && hierarchy != null) node.Caption = "Give the name which needs to be displayed"; } foreach (MetaTreeNode node in olapClient1.AxisElementBuilderColumn.MetaTreeNodes) { var hierarchy = node.Properties.FindByName(PropertyConstants.Hierarchy); var dimension = node.Properties.FindByName(PropertyConstants.Dimension); if (dimension != null && hierarchy != null) node.Caption = " Give the name which needs to be displayed"; } foreach (MetaTreeNode node in olapClient1.AxisElementBuilderSlicer.MetaTreeNodes) { var hierarchy = node.Properties.FindByName(PropertyConstants.Hierarchy); var dimension = node.Properties.FindByName(PropertyConstants.Dimension); if (dimension != null && hierarchy != null) node.Caption = "Give the name which needs to be displayed"; } }
VB
Private Function MainWindow() As Public Try InitializeComponent() Me.olapClient1.OlapDataManager = New Syncfusion.Olap.Manager.OlapDataManager("Data Source=http://bi.syncfusion.com/olap/msmdpump.dll; Initial Catalog=Adventure Works DW 2008 SE;") Me.olapClient1.OlapDataManager.SetCurrentReport(SampleReport()) Me.olapClient1.OlapDataManager.AxisElementChanged += New Syncfusion.Olap.Manager.AxisElementChangedEventHandler(OlapDataManager_AxisElementChanged) Catch ex As Exception MessageBox.Show(ex.Message, "Data will not be loaded properly") End Try End Function Private Sub OlapDataManager_AxisElementChanged(ByVal sender As Object, ByVal e As AxisElementChangedEventArgs) Dim node As MetaTreeNode For Each node In olapClient1.AxisElementBuilderRow.MetaTreeNodes Dim hierarchy As var = node.Properties.FindByName(PropertyConstants.Hierarchy) Dim dimension As var = node.Properties.FindByName(PropertyConstants.Dimension) If Not dimension Is Nothing And hierarchy Is Nothing Then node.Caption = "Give the name which needs to be displayed" End If Next Dim node As MetaTreeNode For Each node In olapClient1.AxisElementBuilderColumn.MetaTreeNodes Dim hierarchy As var = node.Properties.FindByName(PropertyConstants.Hierarchy) Dim dimension As var = node.Properties.FindByName(PropertyConstants.Dimension) If Not dimension Is Nothing And hierarchy Is Nothing Then node.Caption = "Give the name which needs to be displayed" End If Next Dim node As MetaTreeNode For Each node In olapClient1.AxisElementBuilderSlicer.MetaTreeNodes Dim hierarchy As var = node.Properties.FindByName(PropertyConstants.Hierarchy) Dim dimension As var = node.Properties.FindByName(PropertyConstants.Dimension) If Not dimension Is Nothing And hierarchy Is Nothing Then node.Caption = "Give the name which needs to be displayed" End If Next End Sub