ASPxPivotGrid.GetFieldValueInfo(Boolean, Int32) Method
Returns information about the specified field value.
Namespace: DevExpress.Web.ASPxPivotGrid
Assembly: DevExpress.Web.ASPxPivotGrid.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public PivotFieldValueEventArgs GetFieldValueInfo(
bool isColumn,
int fieldValueIndex
)
#Parameters
Name | Type | Description |
---|---|---|
is |
Boolean | true, to specify a column; false, to specify a row. |
field |
Int32 | A zero-based index of the required field value. |
#Returns
Type | Description |
---|---|
Pivot |
A Pivot |
#Remarks
Use the GetFieldValueInfo method in the client-side ASPxClientPivotGrid.PopupMenuItemClick event handler.
To obtain the field value for which the popup menu has been invoked, follow the steps below:
- handle the ASPxClientPivotGrid.PopupMenuItemClick event;
- send a callback to the server by calling the ASPxClientPivotGrid.PerformCallback method. Pass the field area identifier (ASPxClientPivotMenuItemClickEventArgs.Area) and field value index (ASPxClientPivotMenuItemClickEventArgs.FieldValueIndex) as a string of arguments;
- handle the server-side ASPxPivotGrid.CustomCallback event, parse the passed information and obtain the required field value using the ASPxPivotGrid.GetFieldValueInfo method.
#Example
This example demonstrates how to add a custom menu item (“Hide this value”) to the field value popup menu and get information on a clicked field.
In this example, the following API is used:
- ASPxPivotGrid.PopupMenuCreated event is handled to add a custom menu item;
- ASPxPivotGrid.CustomCallback event is handled to process an item click on the server side;
- ASPxClientPivotGrid.PopupMenuItemClick client-side event performs a callback to the server to supply required values to the ASPxPivotGrid.CustomCallback event handler;
- ASPxPivotGrid.GetFieldValueInfo method returns information about the clicked field;
- PivotFieldEventArgsBase<T>.Field property gets the clicked field;
- PivotGridFieldBase.FilterValues property allows filter criteria addition to hide the specified value;
- ASPxPivotGrid.JSProperties property stores the notification string to display on the client side using the JS alert function.
using DevExpress.Web.ASPxPivotGrid;
using System;
using System.Data;
namespace ASPxPivotGrid_AddCustomPopupMenuItem
{
public partial class Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(@"~/App_Data/CustomerReports.xml"));
ASPxPivotGrid1.DataSource = ds.Tables[0];
ASPxPivotGrid1.DataBind();
}
protected void ASPxPivotGrid1_PopupMenuCreated(object sender, PivotPopupMenuCreatedEventArgs e)
{
if (e.MenuType == PivotGridPopupMenuType.FieldValueMenu)
{
e.Menu.Items.Add("Hide this value", "hideValue");
}
}
protected void ASPxPivotGrid1_CustomCallback(object sender, PivotGridCustomCallbackEventArgs e)
{
ASPxPivotGrid pivot = (ASPxPivotGrid)sender;
pivot.JSProperties["cpAlertMessage"] = null;
string[] parameters = e.Parameters.Split(new char[] { '|' });
if (parameters.Length == 5 && parameters[0] == "MenuItemClick")
{
if (parameters[1] == "hideValue")
{
bool isColumn = parameters[4] == "ColumnArea";
PivotFieldValueEventArgs fieldValueInfo = pivot.GetFieldValueInfo(isColumn, Convert.ToInt32(parameters[3]));
if (isColumn)
{
pivot.JSProperties["cpAlertMessage"] = string.Format("Cannot hide the {0} column", fieldValueInfo.Value);
}
else
{
if (fieldValueInfo.Field != null)
fieldValueInfo.Field.FilterValues.Add(fieldValueInfo.Value);
}
}
}
}
}
}