We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Null pointer from SfDataGridHelpers.GetRowHeight before a crash

Thread ID:





130735 May 30,2017 09:12 AM May 31,2017 11:35 PM Xamarin.iOS 1
Tags: SfDataGrid
Clint Anderson
Asked On May 30, 2017 09:12 AM

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:

2017-05-30 08:05:16.580 IosGold[98726:3181915] Unhandled managed exception:
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/ 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  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?

Sivaraman Sivagurunathan [Syncfusion]
Replied On May 31, 2017 11:35 PM

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.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.