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

Serialization Exception

3 Answers 31 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Asuman
Top achievements
Rank 1
Asuman asked on 06 Sep 2015, 05:06 PM

Hi,

My localDataProvider's data structure is dynamic and like this.

public class PeriodicData : CustomTypeHelper<PeriodicData>
    {
    }

In app I'm adding these properties to PeriodicData as follows

PeriodicData.AddProperty("Month", typeof(MyMonth));

PeriodicData.AddProperty("Year", typeof(MyYear));

PeriodicData.AddProperty("Name", typeof(string));

PeriodicData.AddProperty("Sallary", typeof(double));

 

MyMonth and MyYear are similiar structures and like this

    public class MyMonth : IComparable, IComparable<MyMonth>, IEquatable<MyMonth>
    {
        public MyMonth(int month)
        {
            this.Month = month;
        }

        private int _month;
        public int Month
        {
            get
            {
                return _month;
            }
            set
            {
                this.SortKey = value;
                _month = value;
            }
        }

        private int _sortKey;
        public int SortKey
        {
            get
            {
                return _sortKey;
            }
            private set
            {
                _sortKey = value;
            }
        }

        public override string ToString()
        {
            return this.Month.ToString();
        }

        public int CompareTo(object obj)
        {
            return this.CompareTo(obj as MyMonth);
        }

        public override bool Equals(object obj)
        {
            return this.Equals(obj as MyMonth);
        }

        public override int GetHashCode()
        {
            return this.SortKey.GetHashCode();
        }

        public int CompareTo(MyMonth otherMonth)
        {
            if (otherMonth != null)
            {
                return this.SortKey.CompareTo(otherMonth.SortKey);
            }

            return 0;
        }

        public bool Equals(MyMonth otherMonth)
        {
            if (otherMonth != null)
            {
                return this.Month.Equals(otherMonth.Month);
            }

            return false;
        }
    }

 

When I want to serialize the radpivotgrid data I'm getting the exception below and I don't know how to modify method below

        public string Serialize(object context)
        {
            string serialized = string.Empty;

            IDataProvider dataProvider = context as IDataProvider;
            if (dataProvider != null)
            {
                MemoryStream stream = new MemoryStream();

                DataProviderSettings settings = new DataProviderSettings()
                {
                    Aggregates = dataProvider.Settings.AggregateDescriptions.OfType<object>().ToArray(),
                    Filters = dataProvider.Settings.FilterDescriptions.OfType<object>().ToArray(),
                    Rows = dataProvider.Settings.RowGroupDescriptions.OfType<object>().ToArray(),
                    Columns = dataProvider.Settings.ColumnGroupDescriptions.OfType<object>().ToArray(),
                    AggregatesLevel = dataProvider.Settings.AggregatesLevel,
                    AggregatesPosition = dataProvider.Settings.AggregatesPosition
                };

                DataContractSerializer serializer = new DataContractSerializer(typeof(DataProviderSettings), KnownTypes);
                serializer.WriteObject(stream, settings);

                stream.Position = 0;
                var streamReader = new StreamReader(stream);
                serialized += streamReader.ReadToEnd();
            }

            return serialized;
        }

 

Best regards...

3 Answers, 1 is accepted

Sort by
0
Asuman
Top achievements
Rank 1
answered on 06 Sep 2015, 08:40 PM

Sorry, I've forgotten something again.

I'm getting the exception just after I apply filter for MyYear or MyMonth and then trying to serialize the dataprovider.

Best regards.

0
Asuman
Top achievements
Rank 1
answered on 07 Sep 2015, 08:28 AM

Sory, I've found the solution at the telerik documentation link http://docs.telerik.com/devtools/silverlight/controls/radpivotgrid/features/localdatasourceprovider/serialization

 Best regards.​

0
Accepted
Nasko
Telerik team
answered on 08 Sep 2015, 05:27 AM
Hi Asuman,

We are glad to here that you were able to achieve the desired using our documentation.

Please, if you have any additional questions or concerns regarding Telerik control do not hesitate to contact us.

Regards,
Nasko
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
PivotGrid
Asked by
Asuman
Top achievements
Rank 1
Answers by
Asuman
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or