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

RadGridView Column order saving fail

1 Answer 383 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Auvo
Top achievements
Rank 1
Auvo asked on 19 Nov 2015, 11:33 AM

Hi,

I'm trying to save RadGridView columns order by using Persistance manager:

                PersistenceManager manager = new PersistenceManager();
                manager.AllowCrossVersion = true;
                stream = manager.Save(radGridView);

 

And

Reading back:

                PersistenceManager manager = new PersistenceManager();
                stream.Position = 0L;
                manager.Load(radGridView, stream);

I change order using drag and drop  and then saving the radgridview.

Sometimes order is right, but many times order is something else that I save.

What is the problem? I sent your simple project that you can verified the problem.

 

Save button is saving grid on the stream.

Format button is return grid in original order.

Get button is loadin order in the stream.

 Here is to prosess:

1. Start to program.

2. Change column order

3. Press Save button.

4. Load original order.

5. Press Get Button.

Some times order is correct and some times is not.


 

 

Here is the c# colde:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.GridView;
using System.Data;
using System.Collections;
using Microsoft.Win32;
using Telerik.Windows.Documents.FormatProviders.Pdf;
using System.IO;
using System.Xml.Serialization;
using System.Globalization;
using Telerik.Windows.Persistence;
using Telerik.Windows.Zip;
using Telerik.Windows.Persistence.Services;
using Telerik.Windows.DragDrop;
using Telerik.Windows.DragDrop.Behaviors;
using System.IO.IsolatedStorage;

namespace GRID_TESTI
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        AlarmDataCls ac = new AlarmDataCls();
        public Page1()
        {
            InitializeComponent();
            ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
            LoadColumns();
        }
        private Stream stream = null;
        public void LoadColumns()
        {

            AlarmDataCls ac = new AlarmDataCls();
            IList data = new ObservableCollection<AlarmDataCls>();

            radGridView.ItemsSource = null;
            radGridView.ItemsSource = data;


        }



        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            radGridView.Rebind();
            SaveToStream();

        }

        private void btnBring_Click(object sender, RoutedEventArgs e)
        {

            OpenFromStream();
        }

        private void SaveToStream()
        {
            try
            {
                PersistenceManager manager = new PersistenceManager();
                manager.AllowCrossVersion = true;
                stream = manager.Save(radGridView);
            }
            catch (Exception ex)
            {
            }
        }

        private void OpenFromStream()
        {
            try
            {
                PersistenceManager manager = new PersistenceManager();
                stream.Position = 0L;
                manager.Load(radGridView, stream);

            }
            catch (Exception ex)
            {

            }

        }
        private void btnAlusta_Click(object sender, RoutedEventArgs e)
        {
            LoadColumns();
        }

        public class AlarmDataCls
        {

            public AlarmDataCls()
            {

            }
            public string Eka
            {
                get;
                set;
            }
            public int Toka
            {
                get;
                set;
            }
            public int Kolmas
            {
                get;
                set;
            }
            public int Neljas
            {
                get;
                set;
            }
            public int Viides
            {
                get;
                set;
            }
            public int Kuudes
            {
                get;
                set;
            }
            public int Seiska
            {
                get;
                set;
            }
            public int Kasi
            {
                get;
                set;
            }
            public int Ysi
            {
                get;
                set;
            }
            public int Kymppi
            {
                get;
                set;
            }

            public int Yksitoista
            {
                get;
                set;
            }
            public int Kaksitoista
            {
                get;
                set;
            }
            public int Kolmetoista
            {
                get;
                set;
            }
            public int Neljatoista
            {
                get;
                set;
            }
        }


    }
}
    

And here is the Xaml:

 

<Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="GRID_TESTI.Page1"
      mc:Ignorable="d"
      d:DesignHeight="300" d:DesignWidth="1300"
      Title="Page1">
    <Grid>
        <telerik:RadGridView  telerik:PersistenceManager.StorageId="radGridView"  
                        AutoGenerateColumns="true"                       
                        Margin="0,40,0,0"
                        Name="radGridView"
                        AllowDrop="True"
                        GroupRenderMode="Flat" Height="500">
        </telerik:RadGridView>
        <Button x:Name="btnSave" Content="Save" HorizontalAlignment="Left" Height="30" Margin="78,10,0,0" VerticalAlignment="Top" Width="120" Click="btnSave_Click"/>
        <Button x:Name="btnBring" Content="Get" HorizontalAlignment="Left" Height="30" Margin="220,10,0,0" VerticalAlignment="Top" Width="120" Click="btnBring_Click"/>
        <Button x:Name="btnAlusta" Content="Format" HorizontalAlignment="Left" Height="25" Margin="555,10,0,0" VerticalAlignment="Top" Width="100" Click="btnAlusta_Click"/>
    </Grid>


</Page>

 

 

Best Regards

Auvo K

 

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Nov 2015, 10:52 AM
Hi ,

Thank you for the provided code snippet. I am afraid we couldn't reproduce this issue on our side. Could you send us more details how you are implementing the GridViewCustomPropertyProvider class? We have a similar working project in our SDK Sample Browser where you can see how to implement ​Save and Load functionality of the RadGridView control's UI. The example is called GridViewSerialization and uyou can also find it in our GitHub SDK repository.

Please take a look at the example and let us know if you have any other questions.

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PersistenceFramework
Asked by
Auvo
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or