Skip to main content
A newer version of this page is available. .

ASPxPivotGrid.CustomSaveCallbackState Event

Allows you to preserve the ASPxPivotGrid’s callback state in a custom manner.

Namespace: DevExpress.Web.ASPxPivotGrid

Assembly: DevExpress.Web.ASPxPivotGrid.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

public event PivotGridCallbackStateEventHandler CustomSaveCallbackState

Event Data

The CustomSaveCallbackState event's data class is PivotGridCallbackStateEventArgs. The following properties provide information specific to this event:

Property Description
CallbackState Gets or sets the ASPxPivotGrid’s callback state.
Handled Gets or sets whether a callback state saving/loading operation is handled manually, so no default processing is required.

Remarks

By default, the ASPxPivotGrid stores its intermediate state (callback state) in a specific hidden CallbackState field within a web page. In some cases, especially when the ASPxPivotGrid is connected to a huge OLAP cube, this state can be rather large, thereby affecting your web application performance. To reduce the web page size, you can store the ASPxPivotGrid’s callback state in a custom manner, for instance, in the Session object or a static variable. For this purpose, you should handle the CustomSaveCallbackState and ASPxPivotGrid.CustomLoadCallbackState events.

Handling the CustomSaveCallbackState event, you can obtain the ASPxPivotGrid’s callback state (via the PivotGridCallbackStateEventArgs.CallbackState property) and save it manually. Set the PivotGridCallbackStateEventArgs.Handled property to true within the event’s handler to use a custom saving / loading mechanism instead of the default.

Note

Note that if you do not handle the CustomSaveCallbackState and ASPxPivotGrid.CustomLoadCallbackState events, the ASPxPivotGrid’s callback state depends on the System.Web.UIControl.UniqueID property value.

Example

This example demonstrates how the ASPxPivotGrid.CustomSaveCallbackState and ASPxPivotGrid.CustomLoadCallbackState events can be handled to preserve the ASPxPivotGrid’s callback state within a Session.

View Example

using System;
using DevExpress.Web.ASPxPivotGrid;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {

    }
    string GetPivotStateID(ASPxPivotGrid pivotGrid) {
        return GetType().FullName + "_" + pivotGrid.ID;
    }
    protected void ASPxPivotGrid1_CustomSaveCallbackState(object sender, 
                                  PivotGridCallbackStateEventArgs e) {
        Session[GetPivotStateID((ASPxPivotGrid)sender)] = e.CallbackState;
        e.CallbackState = null;
        e.Handled = true;
    }
    protected void ASPxPivotGrid1_CustomLoadCallbackState(object sender, 
                                  PivotGridCallbackStateEventArgs e) {
        e.CallbackState = (string)Session[GetPivotStateID((ASPxPivotGrid)sender)];
        e.Handled = true;
    }
}
See Also