Drag and Drop Cast Error when DataSource is sorted

Hi,

I would want to report an exception when you apply the Drag and Drop sample and replace the DataSource by GridData.OrderBy(x => x.OrderID).


The exception thrown is :

System.InvalidCastException: Specified cast is not valid.

   at Syncfusion.Blazor.Data.BlazorAdaptor.BatchUpdate


Ordering while enabling Drag and Drop is probably a confusing idea but maybe this error could be catched on your side.


Regards


1 Reply 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team July 1, 2022 01:12 PM UTC

Hi Julien,


Greetings from Syncfusion support.


Query: “I would want to report an exception when you apply the drag and drop sample and replace the DataSource by GridData.OrderBy(x => x.OrderID).”


We have checked your query and we could able to reproduce the reported issue when using OrderBy in Datasource property. To resolve the reported issue we suggest you to convert the DataSource to list after performing OrderBy operations. Kindly refer the attached code snippet for your reference.


<SfGrid DataSource="@Orders.OrderByDescending(x=> x.OrderID).ToList()" @ref="Grid" AllowRowDragAndDrop="true" AllowPaging="true">

    <GridColumns>

...

    </GridColumns>

</SfGrid>



Kindly get back to us if you have further queries.


Regards,

Monisha



Marked as answer
Loader.
Up arrow icon