How to check whether measure is present or not in the column and row axes?
You can check the presence of measure in row or column axes using AxisElementBuilder’s PreRender that is explained in 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)
{
if (this.OlapClient1.AxisElementBuilderColumn.Controls.Count > 0 && this.OlapClient1.AxisElementBuilderColumn.Controls[0].Controls.Count > 0 && this.OlapClient1.AxisElementBuilderColumn.Controls[0].Controls[0] is Label)
{
for (var i = 0; i < this.OlapClient1.AxisElementBuilderColumn.Controls.Count; i++)
{
if (!(OlapClient1.AxisElementBuilderColumn.Controls[i] is SplitButton)) continue;
if (((Label)OlapClient1.AxisElementBuilderColumn.Controls[i].Controls[0]).Text == "Measures")
{
bool isInColumn = true;
}
}
}
}
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) If Me.OlapClient1.AxisElementBuilderColumn.Controls.Count > 0 AndAlso Me.OlapClient1.AxisElementBuilderColumn.Controls(0).Controls.Count > 0 AndAlso TypeOf Me.OlapClient1.AxisElementBuilderColumn.Controls(0).Controls(0) Is Label Then For i = 0 To Me.OlapClient1.AxisElementBuilderColumn.Controls.Count - 1 If Not(TypeOf OlapClient1.AxisElementBuilderColumn.Controls(i) Is SplitButton) Then Continue For End If If (CType(OlapClient1.AxisElementBuilderColumn.Controls(i).Controls(0), Label)).Text = "Measures" Then Dim isInColumn As Boolean = True End If Next i End If End Sub