Error when doing more than 1 deserialize action on a SfDataGrid

I have a 'load settings' option for my grid where the user can choose to load a settings file.

Every time, the first call of Deserialize() works perfectly.  The second try forward on the same instance of the grid always fails with the following error message:

Object reference not set to an instance of an object.
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.OnDetailsViewDefinitionChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
   at Syncfusion.UI.Xaml.Grid.GridPropertyMetadata.OnDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at Syncfusion.UI.Xaml.Grid.GridPropertyMetadata.OnInternalDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Syncfusion.UI.Xaml.Grid.SerializationController.RestoreDetailsViewDefinition(SerializableDataGrid serializableDataGrid, DeserializationOptions options)
   at Syncfusion.UI.Xaml.Grid.SerializationController.RestoreGridSettings(SerializableDataGrid serializableDataGrid, SfDataGrid dataGrid, DeserializationOptions options)
   at Syncfusion.UI.Xaml.Grid.SerializationController.ReloadGrid(SerializableDataGrid dataGrid, DeserializationOptions deserializationOptions)
   at Syncfusion.UI.Xaml.Grid.SerializationController.Deserialize(Stream stream, DeserializationOptions deserializeOptions)
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.Deserialize(Stream stream)

This happens regardless of the order I choose to execute the different items.

Interestingly, after this happens the column layouts are deserialized correctly, but the grouping functionality goes wrong. I can still drag columns into the grid header, but the grouping does not happen and the group summaries are not shown.

Any insight into what is happening?

2 Replies

VS Vijayarasan Sivanandham Syncfusion Team March 4, 2020 06:11 PM UTC

Hi Phil Nixon,

We have analyzed your query that “Error when doing more than 1 deserialize action on a SfDataGrid”. We have tried to replicate your scenario but we are unable to reproduce the reported issue from our end. Please find the tested sample and video demo from our end in the below link,

Sample Link: https://www.syncfusion.com/downloads/support/forum/152129/ze/Sample989732021 
Video Link: https://www.syncfusion.com/downloads/support/forum/152129/ze/Deserialization745992219

If still you are facing the same issue, can you please share us below things? 
1.       Code files related to you command  
2.       Brief replication procedure/video illustration of the reported issue 
 
Also if possible, can you please revert us with the modified sample? It will help us to investigate further and provide appropriate solution at earlier.

Regards, 
Vijayarasan S 



CC Chad Church Syncfusion Team March 11, 2020 03:06 PM UTC

Thanks Jay.

 

I did a bit more testing and found that if I create a custom SerializationController and wrap the RestoreDetailsViewDefinition() method in an exception handler, then the rest of the grid seems to deserialize correctly.  So the bug / need for exception handling is something to do with what’s happening in that method.

 

public class CustomSfGridSerializer : SerializationController

    {

        private static Logger _logger = LogManager.GetCurrentClassLogger();

 

        public CustomSfGridSerializer(SfDataGrid dataGrid)

           : base(dataGrid)

        {

        }

 

        protected override void RestoreDetailsViewDefinition(SerializableDataGrid serializableDataGrid, DeserializationOptions options)

        {

            try

            {

                base.RestoreDetailsViewDefinition(serializableDataGrid, options);

            }

            catch (Exception e)

            {

                _logger.Info("CustomSfGridSerializer caught and handled an error that should have been dealt with by Syncfusion");

            }

        }

    }

 

Regards,

Phil


Loader.
Up arrow icon