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

ASPxPivotGrid.SaveCollapsedStateToStream(Stream) Method

Saves the collapsed state of field values to the specified stream.

Namespace: DevExpress.Web.ASPxPivotGrid

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

Declaration

public void SaveCollapsedStateToStream(
    Stream stream
)

Parameters

Name Type Description
stream Stream

A Stream descendant to which the collapsed state of field values is saved.

Remarks

The saved settings can then be restored using the ASPxPivotGrid.LoadCollapsedStateFromStream method.

Note

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.

Example

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.Dispose();
            }
            collapseStateStream = new MemoryStream();
            ASPxPivotGrid1.SaveCollapsedStateToStream(collapseStateStream);
            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) {
                return;
            }
            ASPxPivotGrid1.LoadLayoutFromString(layout, PivotGridWebOptionsLayout.DefaultLayout  );
            collapseStateStream.Seek(0, SeekOrigin.Begin);
            ASPxPivotGrid1.LoadCollapsedStateFromStream(collapseStateStream);
        }
        protected void btnClear_Click(object sender, EventArgs e) {
            ASPxPivotGrid1.Fields.Clear();
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SaveCollapsedStateToStream(Stream) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also