New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Custom Serialization Provider

empty
QuantityYearQuarter
ProductName
19971997 Total 19981998 TotalGrand Total
Quarter 1Quarter 2Quarter 3Quarter 4Quarter 1Quarter 2Quarter 3Quarter 4
36.0028.5716.5060.0029.2812.0041.6713.259.0019.7325.66
20.0055.006.0018.0027.1425.0027.67  27.0027.09
22.7525.6724.0022.4423.8418.3338.3351.5015.0030.3025.69
25.1738.3317.0035.7131.6721.7531.60100.0022.0028.5330.18
22.83 15.0028.7523.5017.6718.3325.006.0015.1019.68
23.1425.0324.7023.3724.0726.0020.7925.5322.8423.5123.85
Alice Mutton
Aniseed Syrup
Boston Crab Meat
Camembert Pierrot
Carnarvon Tigers
Grand Total
Page 1 of 16

In this example you can see how to preserve the state of RadPivotGrid using a custom serializer provider. The custom serializer provider implements IStateSerializer interface containing Serialize, Deserialize and DeserializeCollection methods which are used by the PersistenceManager to load/save the state. To demonstrates this functionality we construct a BinaryFormatter and use it to serialize/deserialize the RadControlState to the MemoryStream.

  • DefaultVB.aspx
  • BinarySerializerVB.vb
    • BinarySerializerVB.vb
    • DefaultVB.aspx.vb
  • styles.css
<%@ Page Title="" Language="VB"  AutoEventWireup="false"
    CodeFile="DefaultVB.aspx.vb" Inherits="PersistenceFramework_Examples_CustomStorageProvider_DefaultVB" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadPersistenceManager ID="RadPersistenceManager1" runat="server" StorageProviderKey="MyProviderKey">
        <PersistenceSettings>
            <telerik:PersistenceSetting ControlID="RadPivotGrid1" />
        </PersistenceSettings>
    </telerik:RadPersistenceManager>
    <div class="demo-container">
        <div class="demo-settings">
            <telerik:RadButton RenderMode="Lightweight" ID="SaveButton" Text="Save State" runat="server" OnClick="SaveButton_Click">
            </telerik:RadButton>
            <telerik:RadButton RenderMode="Lightweight" ID="LoadButton" Text="Load State" runat="server" OnClick="LoadButton_Click">
            </telerik:RadButton>
            <telerik:RadButton RenderMode="Lightweight" ID="ResetButton" Text="Reset State" runat="server" OnClick="ResetButton_Click">
            </telerik:RadButton>
        </div>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadPivotGrid RenderMode="Lightweight" runat="server" ID="RadPivotGrid1" AllowPaging="true" PageSize="5"
                OnNeedDataSource="RadPivotGrid1_NeedDataSource" Width="100%" AllowSorting="true"
                AllowFiltering="false" ShowFilterHeaderZone="false">
                <PagerStyle Mode="Slider" AlwaysVisible="true"></PagerStyle>
                <Fields>
                    <telerik:PivotGridColumnField DataField="Year" Caption="Year" UniqueName="Discount">
                    </telerik:PivotGridColumnField>
                    <telerik:PivotGridColumnField DataField="Quarter" Caption="Quarter" DataFormatString="Quarter {0}" UniqueName="UnitPrice">
                    </telerik:PivotGridColumnField>
                    <telerik:PivotGridAggregateField DataField="Quantity" Caption="Quantity" UniqueName="Quantity"
                        Aggregate="Average" DataFormatString="{0:F2}">
                    </telerik:PivotGridAggregateField>
                    <telerik:PivotGridRowField DataField="ProductName" Caption="ProductName" UniqueName="ProductName">
                    </telerik:PivotGridRowField>
                    <telerik:PivotGridRowField IsHidden="true" DataField="TotalPrice" Caption="OrderID"
                        UniqueName="OrderID" DataFormatString="{0:F2}">
                    </telerik:PivotGridRowField>
                </Fields>
            </telerik:RadPivotGrid>
        </telerik:RadAjaxPanel>
    </div>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance