This is a migrated thread and some comments may be shown as answers.

Save RadPivotGrid in xml file

1 Answer 21 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
amine
Top achievements
Rank 1
amine asked on 13 Dec 2013, 10:11 AM

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



1 Answer, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 13 Dec 2013, 01:50 PM
Hello,

I suggest you to take a look at this example in our SDK Repository. It contains the full code you need in order to achieve your goal.

Hope this helps.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PivotGrid
Asked by
amine
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question
or