In a few of my grids I receive a null pointer exception when I query the row height with SfDataGridHelpers.GetRowHeight. I put that one in a try/catch to get more info and to let the code continue on. After that passes however, I also an error:
Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
at Syncfusion.Data.Extensions.PropertyDescriptorExtensions.GetComplexPropertyValue (System.String propertyNameList, System.ComponentModel.PropertyDescriptorCollection tempitempproperties, System.Object record) [0x000c4] in <9753741c30de45aaad3bdc3a67541094>:0
at Syncfusion.Data.ItemPropertiesProvider.GetValue (System.Object record, System.String property) [0x0005d] in <9753741c30de45aaad3bdc3a67541094>:0
at Syncfusion.SfDataGrid.SfDataGridHelpers.GetCellValue (Syncfusion.SfDataGrid.SfDataGrid datagrid, System.Object recorddata, System.String columnname) [0x0001b] in <3680b4a196e04dda8d88dda86ec712c6>:0
The given key was not present in the dictionary. (System.Collections.Generic.KeyNotFoundException)
at System.ThrowHelper.ThrowKeyNotFoundException () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:68
at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/referencesource/mscorlib/system/collections/generic/dictionary.cs:183
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object,System.Exception&)
I believe the issue here is that I am using a Dictionary<string,object> as my datasource, and some rows may not contain all of the fields for some of the columns. So if a column is mapped to something like Values[optionalValue], and optionalValue does not exist for a row, the whole table crashes. Is there a way to tell the grid to handle missing values with either a null value , empty string or some other non-exception scenerio?
SSSivaraman Sivagurunathan Syncfusion Team June 1, 2017 03:35 AM UTC
Hi Clint Anderson,
Thanks for contacting Syncfusion Support.
We have checked your query. The reported exception occurs when you pass null values to SfDataGrid when using Dictionary. When, using Dictionary the datasource is set by the key value. If some field does not exist in the given key then the exception will occur. To resolve the issue you have to set empty data rather than setting null value.