Save RadPivotGrid in xml file

2 posts, 0 answers
  1. amine
    amine avatar
    9 posts
    Member since:
    Apr 2011

    Posted 13 Dec 2013 Link to this post

    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



  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 13 Dec 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top