)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display the measure name instead of showing "Measures" in AxisElementBuilder ?

Platform: ASP.NET Web Forms (Classic) |
Control: OlapClient |
Published Date: January 23, 2015 |
Last Revised Date: July 2, 2019

This KB illustrates that how to display the measure name instead of showing “Measures”  AxisElementBuilder.

Solution

Displaying measure name instead of showing “Measures” in SplitButton in AxisElementBuilder can be achieved through the following code example.

C#

protected void Page_Load(object sender, EventArgs e)
{
     this.OlapClient1.AxisElementBuilderColumn.PreRender += AxisElementBuilderColumn_PreRender;
}
void AxisElementBuilderColumn_PreRender(object sender, EventArgs e)
{
    int i = 0;
    foreach (var spltBtn in this.OlapClient1.AxisElementBuilderColumn.SplitButtonCollection.Values)
    {
        if ((spltBtn.Controls[0] as Label).Text == "Measures" && this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue is MeasureElements)
        {
             (spltBtn.Controls[0] as Label).Text = (this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue as MeasureElements).Elements[0].Name;
             //Or if you have assigned only unique name in report you can manipulate the string below accordingly to get the measure name.
             (spltBtn.Controls[0] as Label).Text = (this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue as MeasureElements).Elements[0].UniqueName.Replace("[","").Replace("]","").Replace(".","").Replace("Measures","");
         }
         i++;
     }
}

VB

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  AddHandler Me.OlapClient1.AxisElementBuilderColumn.PreRender, AddressOf AxisElementBuilderColumn_PreRender
End Sub
Private Sub AxisElementBuilderColumn_PreRender(ByVal sender As Object, ByVal e As EventArgs)
 Dim i As Integer = 0
 For Each Dim spltBtn In Me.OlapClient1.AxisElementBuilderColumn.SplitButtonCollection.Values
  If (TryCast(spltBtn.Controls(0), Label)).Text = "Measures" AndAlso TypeOf Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue Is MeasureElements Then
    (TryCast(spltBtn.Controls(0), Label)).Text = (TryCast(Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue, MeasureElements)).Elements(0).Name
    'Or if you have assigned only unique name in report you can manipulate the string below accordingly to get the measure name.
    (TryCast(spltBtn.Controls(0), Label)).Text = (TryCast(Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue, MeasureElements)).Elements(0).UniqueName.Replace("[","").Replace("]","").Replace(".","").Replace("Measures","")
  End If
   i += 1
 Next spltBtn
End Sub

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon