Hi Telerik,
For two days, I try to find a way to save and load the state of RadPivotGrid in an xml file. But without success
This is what I did:
to save the state :
private
void
Saveit()
{
try
{
PersistenceManager manager =
new
PersistenceManager();
this
.stream = manager.Save(
this
.Pivot.DataProvider);
byte
[] fileBytes = ReadFully(stream);
SaveFileDialog dialog =
new
SaveFileDialog();
dialog.Filter =
"Pivot Files (.Pvt)|*.Pvt|All Files (*.*)|*.*"
;
//Show the dialog
bool
? dialogResult = dialog.ShowDialog();
if
(dialogResult !=
true
)
return
;
//Get the file stream
using
(Stream fs = (Stream)dialog.OpenFile())
{
fs.Write(fileBytes, 0, fileBytes.Length);
fs.Close();
//File successfully saved
}
}
catch
(Exception ex)
{
//inspect ex.Message
}
}
to load it :
private
void
Openit()
{
try
{
OpenFileDialog _openFileDialog =
new
OpenFileDialog();
_openFileDialog.Filter =
"Pivot Files (.Pvt)|*.Pvt|All Files (*.*)|*.*"
;
_openFileDialog.Multiselect =
false
;
bool
? dialogResult = _openFileDialog.ShowDialog();
if
(dialogResult.Value)
{
Stream fileStream = _openFileDialog.File.OpenRead();
using
(StreamReader reader =
new
StreamReader(fileStream))
{
//FileTextBox.Text = reader.ReadToEnd();
using
(var memstream =
new
MemoryStream())
{
reader.BaseStream.CopyTo(memstream);
PersistenceManager manager =
new
PersistenceManager();
manager.Load(
this
.Pivot.DataProvider, memstream);
}
}
fileStream.Close();
}
}
catch
{ }
}
I added the two classes "DataProviderSettings" and "DataProviderValueProvider". and I added the line:
ServiceProvider.RegisterPersistenceProvider<IValueProvider>(typeof(XmlaDataProvider), new XmlaValueProvider());
But I get an error message : Can not convert 'ApplicationWeb.Layouts_Cube.XmlaValueProvider' to 'Telerik.Windows.Persistence.Services.IPersistenceProvider'
thank you