Skip to main content

ASPxPivotGrid.LoadCollapsedStateFromString(String) Method

Restores the collapsed state of field values from the specified string.

Namespace: DevExpress.Web.ASPxPivotGrid

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

NuGet Package: DevExpress.Web


public void LoadCollapsedStateFromString(
    string collapsedState


Name Type Description
collapsedState String

A String from which the collapsed state of field values is read.


Use the LoadCollapsedStateFromString method to load the collapsed state of field values that has been written to a string via the ASPxPivotGrid.SaveCollapsedStateToString method.

The collapsed states of field values can only be restored in the same layout they were saved in. If the control layout was changed after saving the collapsed states (for instance, some fields have been reordered or hidden), the LoadCollapsedStateFromString method may have no effect, or may restore the collapsed states incorrectly. To ensure that the collapsed states are loaded correctly, prevent end-users from changing the control layout (use the PivotGridOptionsCustomization.AllowDrag property), or save and load the field values’ collapsed states together with the control layout (use the ASPxPivotGrid.SaveLayoutToString and ASPxPivotGrid.LoadLayoutFromString methods).


The LoadCollapsedStateFromString method has no effect if used when data is not loaded (i.e. the ASPxPivotGrid.DataSource property is not initialized).


The collapsed states for server mode and regular data sources are stored in different formats and not compatible with each other. Some issues can appear on restoring the collapsed state from different data source modes.


Field values' collapsed states can be restored only in the same layout they have been saved in. This example shows how to save and load a control's layout together with collapsed states to ensure that the states are loaded in the appropriate layout.

using System;
using System.IO;
using System.Web.UI;
using DevExpress.Utils;
using DevExpress.Web.ASPxPivotGrid;

namespace ASPxPivotGrid_SaveLoadCollapsedState {
    public partial class _Default : Page {
        protected void btnSave_Click(object sender, EventArgs e) {
            Session["Layout"] = ASPxPivotGrid1.SaveLayoutToString( PivotGridWebOptionsLayout.DefaultLayout );
            MemoryStream collapseStateStream = (MemoryStream)(Session["CollapseStateStream"]);
            if (collapseStateStream != null) {
            collapseStateStream = new MemoryStream();
            Session["CollapseStateStream"] = collapseStateStream;
        protected void btnLoad_Click(object sender, EventArgs e) {
            MemoryStream collapseStateStream = (MemoryStream)(Session["CollapseStateStream"]);
            string layout = (string)(Session["Layout"]);
            if (layout == null ||
                collapseStateStream == null) {
            ASPxPivotGrid1.LoadLayoutFromString(layout, PivotGridWebOptionsLayout.DefaultLayout  );
            collapseStateStream.Seek(0, SeekOrigin.Begin);
        protected void btnClear_Click(object sender, EventArgs e) {
See Also