Android SfDatagrid throws exception using latest version

I am having a simple datagrid like below but it is crashing randomly for some reason i dont understand why. SelectedReportModel is never null, it is always filled

 <sfgrid:SfDataGrid ScrollingMode="PixelLine" HorizontalOptions="FillAndExpand" Grid.Row="0"
                         x:Name="dataGrid"                        
                         AutoGenerateColumns="False"
                         AllowSorting="True"                      
                         ColumnSizer="Auto"                           
                         RowHeight="30"                        
                         AllowSwiping="False"  
                         SelectedItem="{Binding SelectedReportModel}"
                         SelectionMode="Single"   ItemsSource="{Binding  ReportModels}">
                <sfgrid:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">                         
                    <sfgrid:GridTextColumn IsHidden="True"
                                MappingName="Id" />
                    <sfgrid:GridTextColumn HeaderText="{resx:Translate Name}"
                                MappingName="Name" />
                    <sfgrid:GridTextColumn HeaderText="{resx:Translate  Reps}"
                                 MappingName="TotalReps" />
                    <sfgrid:GridTextColumn HeaderText="{resx:Translate Sets}"
                               MappingName="TotalSets" />
                    <sfgrid:GridTextColumn HeaderText="{resx:Translate WeightTotal}"
                                 MappingName="TotalliftText" />

                </sfgrid:SfDataGrid.Columns>

            </sfgrid:SfDataGrid>

07-14 14:58:43.352 I/MonoDroid(13664): System.NullReferenceException: Object reference not set to an instance of an object.
07-14 14:58:43.352 I/MonoDroid(13664):   at Syncfusion.SfDataGrid.XForms.GridSelectionController.ProcessSelectedItemChanged (Syncfusion.SfDataGrid.XForms.SelectionPropertyChangedHandlerArgs args) [0x0004d] in <d98eb5c9e27e40c0b7c8b6429b7f0f3b>:0 
07-14 14:58:43.352 I/MonoDroid(13664):   at Syncfusion.SfDataGrid.XForms.GridSelectionController.HandleSelectionPropertyChanges (Syncfusion.SfDataGrid.XForms.SelectionPropertyChangedHandlerArgs args) [0x0003c] in <d98eb5c9e27e40c0b7c8b6429b7f0f3b>:0 
07-14 14:58:43.352 I/MonoDroid(13664):   at Syncfusion.SfDataGrid.XForms.SfDataGrid.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00055] in <d98eb5c9e27e40c0b7c8b6429b7f0f3b>:0 
07-14 14:58:43.352 I/MonoDroid(13664):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 
07-14 14:58:43.353 I/MonoDroid(13664):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:417 
07-14 14:58:43.353 I/MonoDroid(13664):   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00216] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:173 

2 Replies

EM Emil July 15, 2018 12:15 PM UTC

I just figured out that i had a mistake in my code if i raise ItemSource collection binding after Selecteditem change, it logically throws exception. But i think that it shouldnt crash the application and throw exception. this is the behavior on xamarin forms listview. maybe you can fix it that it doesnt throw exception but just do nothing instead.


SR Sivakumar R Syncfusion Team July 17, 2018 12:40 PM UTC

Hi Emil, 
 
We have tried to reproduce the reported exception with our latest version of datagrid (16.2.0.42) version. SelectedItem binding works as expected.  
 
 
Sample: 
 
Can you please let us know whether you are changing ItemsSource and SelectedItem at runtime? Or you are facing exception while loading itself? 
 
Thanks, 
Sivakumar 


Loader.
Up arrow icon