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. Image for the cookie policy date
close icon

RowData is null in Find is not valid operation

Hi,

In my Xamarin form project AFTER UPGRADING sfDataGrid from 17.3.x to 17.4.x, when try to set the grid selected item I keep receiving 'RowData is null in Find is not valid operation sfdatagrid' exception!

if (dgGrid.View?.Records.Count > 0)
{
    dgGrid.SelectedItem = dgGrid.View.Records[0].Data;
}

any thoughts or suggestion? 

6 Replies

KK Karthikraja Kalaimani Syncfusion Team January 13, 2020 12:15 PM UTC

Hi Behzad,

Thanks for contacting Syncfusion support.

We have checked the reported issue “RowData is null in find is not valid operation” and we are unable to reproduce the issue in our end and it is working fine as expected. We have attached the tested sample for your reference.

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGrid_Demo22021724359.zip


Video link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Video_Reference1910780977.zip


Xamarin Forms Version : 4.4.0.991265

SfDataGrid Version : 17.4.0.41 & 17.3.0.34

Please let us know the following  details,

* SfDataGrid settings
* Which platform you are facing the issue ?
* Xamarin Forms Version
* Which way you have tried to get Record Data ?


Regards,
Karthik Raja 



MV Malcolm van Staden October 10, 2022 04:08 PM UTC

Hi, a google search led me here as I was having the same problem.

I have a grid where I change the ItemsSource quite frequently along with the SelectedItem to match the updated ItemsSource.

I've spent a lot of time trying to debug it and found that the selection state isn't managed properly. What happens is the header row is set as the selected row at some point (I am unsure why it's doing this but believe it has something to do with the modified ItemsSource as well as the SelectedItem being set to null) and then internally during InvalidateSelectionOfRow it iterates over the internal rows to try match it with the changing row, but with the header being set as the selected row, the Contains is called:

r.IsSelectedRow && !base.SelectedRows.Contains(r.RowData)

but r.RowData is null because it's the header row and this in turn calls the Find method which then throws the exception:

internal GridRowInfo Find(object rowData)
{
if (rowData == null)
{
throw new InvalidOperationException("RowData is null in Find is not valid operation");
}
if (base.Count <= 0)
{
return null;
}
return this.FirstOrDefault((GridRowInfo rowInfo) => rowInfo.RowData == rowData);
}

This is still a problem on the version I'm using v20.2.0.46

To work around this I made sure to never set the SelectedItem to null. This seems to prevent the exception from occurring. It's messy. I hope this helps someone.



MV Malcolm van Staden October 10, 2022 04:15 PM UTC

Attached is a sample app replicating this - click Next a few times and at the point that we set the SelectedItem as null, that's when it will throw the exception


Attachment: GettingStarted_71268fe.zip


SV Suja Venkatesan Syncfusion Team October 11, 2022 03:01 PM UTC

Hi Malcolm,


We would like to let you know that we are able to replicate the reported scenario on our end. We will update you with further details on or before October 13, 2022. We appreciate your patience until then.


Regards,

Suja




SV Suja Venkatesan Syncfusion Team October 14, 2022 04:32 AM UTC

Hi Malcolm,


We have logged a bug report for the reported issue “InvalidOperationException thrown when changing SelectedItem as null during runtime ". We will fix the issue and include the fix in our weekly nuget which is scheduled on November 8, 2022. We will let you know once it is released with the fix. You can also track the status of the report from the below link.  


Feedback link:https://www.syncfusion.com/feedback/38383/invalidoperationexception-thrown-when-changing-selecteditem-as-null-during-runtime


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Suja




SV Suja Venkatesan Syncfusion Team November 9, 2022 02:28 PM UTC

We are glad to announce that our Essential Studio 2022 Volume 3 Service Pack Release V20.3.0.56 is rolled out with fix for the issue "InvalidOperationException thrown when changing SelectedItem as null during runtime” and it is available for download under the following link.


https://www.syncfusion.com/forums/178709/essential-studio-2022-volume-3-service-pack-release-v20-3-0-56-is-available-for-download


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.



Loader.
Live Chat Icon For mobile
Up arrow icon