PivotSerializationOptions.RemoveOldFields Attached Property
Gets or sets whether the fields that exist in a layout when it is restored, but don’t currently exist in the PivotGrid, should be discarded. This is an attached property.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v19.2.dll
Declaration
Returns
Type | Description |
---|---|
Boolean | true to discard the fields that exist in the layout being restored but don’t currently exist in the PivotGrid; otherwise, false. |
Remarks
The RemoveOldFields option affects how the PivotGrid’s layout is restored. If it is set to true, the fields that exist in the layout being loaded, but do not exist in the grid, will not be re-created. Otherwise, these fields will be added to the PivotGrid.
To learn more, see Save and Restore Layout.
Example
This example shows how to save (or restore) the PivotGridControl‘s data and layout to a file. To correctly restore fields if the pivot grid’s PivotGridControl.Fields collection is empty, the PivotSerializationOptions.RemoveOldFields
property should be set to false.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-work-with-the-dxpivotgrid-control-offline-e2124.
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Imports HowToBindToMDB.NwindDataSetTableAdapters
Imports System.IO
Imports DevExpress.Xpf.Core
Namespace HowToBindToMDB
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Private salesPersonDataTable As New NwindDataSet.SalesPersonDataTable()
Private salesPersonDataAdapter As New SalesPersonTableAdapter()
Public Sub New()
InitializeComponent()
pivotGridControl1.DataSource = salesPersonDataTable
End Sub
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
salesPersonDataAdapter.Fill(salesPersonDataTable)
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
pivotGridControl1.SavePivotGridToFile("pivot.dat", True)
pivotGridControl1.DataSource = Nothing
pivotGridControl1.Fields.Clear()
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
If (Not File.Exists("pivot.dat")) Then
DXMessageBox.Show("You should save the PivotGrid into a file first")
Return
End If
pivotGridControl1.RestorePivotGridFromFile("pivot.dat")
End Sub
End Class
End Namespace