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.1.dll
NuGet Package:
DevExpress.Web
Declaration
public event PivotGridCallbackStateEventHandler CustomSaveCallbackState
Public Event CustomSaveCallbackState As PivotGridCallbackStateEventHandler
Event Data
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.
|
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.
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;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxPivotGrid.v__, Version=__, Culture=neutral,
PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxPivotGrid" TagPrefix="dxwpg" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server"
OLAPConnectionString="provider=MSOLAP;
data source=https://demos.devexpress.com/Services/OLAP/msmdpump.dll;
initial catalog=Adventure Works DW Standard Edition;
cube name=Adventure Works;"
OnCustomLoadCallbackState="ASPxPivotGrid1_CustomLoadCallbackState"
OnCustomSaveCallbackState="ASPxPivotGrid1_CustomSaveCallbackState">
<Fields>
<dxwpg:PivotGridField ID="fieldCountry1" Area="RowArea" AreaIndex="0"
Caption="Country"
FieldName="[Customer].[Country].[Country]">
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="fieldCity1" Area="RowArea" AreaIndex="1"
Caption="City"
FieldName="[Customer].[City].[City]">
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="fieldCustomerCount" Area="DataArea" AreaIndex="0"
Caption="Customer Count"
FieldName="[Measures].[Customer Count]">
</dxwpg:PivotGridField>
</Fields>
</dxwpg:ASPxPivotGrid>
</div>
</form>
</body>
</html>
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxPivotGrid.v__, Version=__, Culture=neutral,
PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxPivotGrid" TagPrefix="dxwpg" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server"
OLAPConnectionString="provider=MSOLAP;
data source=https://demos.devexpress.com/Services/OLAP/msmdpump.dll;
initial catalog=Adventure Works DW Standard Edition;
cube name=Adventure Works;"
OnCustomLoadCallbackState="ASPxPivotGrid1_CustomLoadCallbackState"
OnCustomSaveCallbackState="ASPxPivotGrid1_CustomSaveCallbackState">
<Fields>
<dxwpg:PivotGridField ID="fieldCountry1" Area="RowArea" AreaIndex="0"
Caption="Country"
FieldName="[Customer].[Country].[Country]">
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="fieldCity1" Area="RowArea" AreaIndex="1"
Caption="City"
FieldName="[Customer].[City].[City]">
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="fieldCustomerCount" Area="DataArea" AreaIndex="0"
Caption="Customer Count"
FieldName="[Measures].[Customer Count]">
</dxwpg:PivotGridField>
</Fields>
</dxwpg:ASPxPivotGrid>
</div>
</form>
</body>
</html>
Imports System
Imports DevExpress.Web.ASPxPivotGrid
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Function GetPivotStateID(ByVal pivotGrid As ASPxPivotGrid) As String
Return Me.GetType().FullName & "_" & pivotGrid.ID
End Function
Protected Sub ASPxPivotGrid1_CustomSaveCallbackState(ByVal sender As Object, ByVal e As PivotGridCallbackStateEventArgs)
Session(GetPivotStateID(DirectCast(sender, ASPxPivotGrid))) = e.CallbackState
e.CallbackState = Nothing
e.Handled = True
End Sub
Protected Sub ASPxPivotGrid1_CustomLoadCallbackState(ByVal sender As Object, ByVal e As PivotGridCallbackStateEventArgs)
e.CallbackState = CStr(Session(GetPivotStateID(DirectCast(sender, ASPxPivotGrid))))
e.Handled = True
End Sub
End Class
See Also