GridColumn of DateTime Does Not Support DateTimeOffset

I am using GridColumn configured in the following way:


 <GridColumn Field=@nameof(CompletedView.Time) HeaderText="When" Type="ColumnType.DateTime" AutoFit="true"> ...


Where CompletedView.Time is a DateTimeOffset.


When filtering this column an exception occurs:

System.InvalidCastException: Unable to cast object of type 'System.DateTimeOffset' to type 'System.Nullable`1[System.DateTime]'. at void Syncfusion.Blazor.Grids.Internal.FilterMenuRenderer<TContent>.BuildRenderTree(RenderTreeBuilder __builder)+(RenderTreeBuilder __builder3) => { } at void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(int sequence, RenderFragment fragment) at void Syncfusion.Blazor.Popups.SfDialog.BuildRenderTree(RenderTreeBuilder __builder)+(RenderTreeBuilder __builder2) => { } [1] at void Microsoft.AspNetCore.Components.CascadingValue<TValue>.Render(RenderTreeBuilder builder) at void Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, out Exception renderFragmentException)


How do I bind a DateTimeOffset to the SfGrid?  Thank you for any assistance you can provide.


11 Replies 1 reply marked as answer

PS Prathap Senthil Syncfusion Team May 30, 2025 01:41 PM UTC

Hi Mike-E,

Before proceeding with the reporting problem, we require some additional clarification from your end. Please share the below details to proceed further at our end.

  • Could you please confirm which filter types are being used in the grid?
  • Could you please share the grid code snippets with the model class?
  • To analyze the reported issue, could you please share a simple and reproducible sample that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.

Above-requested details will be very helpful in validating the reported query at our end and providing a solution as early as possible. Thanks for your understanding.

Regards,
Prathap Senthil



MI Mike-E May 30, 2025 09:13 PM UTC

Hi Prathap,


Thank you very much for your investigation and assistance.  It would be quite a bit of work on my end to provide you a sample.  Perhaps it is easier to ask you: have you been able to verify on your end that the grid works with DateTimeOffset as a property type using the GridColumn configuration as above?


Please note that I am using EntityFramework as the backend provider.  I will see if I can get you a sample.


Thank you for any further assistance you can provide.



MI Mike-E May 30, 2025 09:24 PM UTC

Here is the model used.  It's the `Created` property that I am trying to filter on:



public sealed class SummaryView

{

public Guid Identity { get; init; }


public DateTimeOffset Created { get; set; }


public string Name { get; set; } = default!;


public Guid Author { get; set; }

public string AuthorName { get; set; } = default!;


public uint Purchaser { get; set; }

public string PurchaserName { get; set; } = default!;


public uint Seller { get; set; }

public string SellerName { get; set; } = default!;


public TransactionType Type { get; set; }


public decimal Value { get; init; }

}



MI Mike-E May 30, 2025 09:25 PM UTC

For the column filter settings, this is being used:


new FilterSettings { Operator = Operator.GreaterThanOrEqual, Type = FilterType.Menu }



MI Mike-E June 3, 2025 08:01 AM UTC

Hi @Prathap are you able to provide a sample with a filter between `DateTime?` and DateTimeOffset using the settings above?  I can try seeing if I can reproduce it from there on my side if so.  Thank you for your continued assistance.



PS Prathap Senthil Syncfusion Team June 4, 2025 11:02 AM UTC

Thanks for the patience.


We have confirmed that this an issue and logged a defect report titled  “Exception occurs when reopening menu filter for non-nullable DateTimeOffset column” This fix will be included in our weekly patch release, which is expected to be rolled out on July 1st , 2025. You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.    
 
Exception occurs when reopening menu filter for non-nullable DateTimeOffset column in Blazor | Feedback Portal

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”

We will get back to you once the release is rolled out. Thanks for your understanding.



MI Mike-E June 5, 2025 07:27 AM UTC

Woohoo!  Thank you so much for your patience as well @Prathap and team.  I am so very happy that this was confirmed on your side and wasn't something particular about my codebase.  I am glad to see that it will be fixed so quickly as well.  Thank you again for all your efforts out there!



NP Naveen Palanivel Syncfusion Team June 6, 2025 08:18 AM UTC

Hi Mike-E,


Welcome. We will get back to you once the release is rolled out. Until then we appreciate your patience.


Regards,

Monisha



PS Prathap Senthil Syncfusion Team July 2, 2025 05:15 AM UTC

Thanks for your patience,

We are glad to announce that, we have included the fix for the issue  “Exception occurs when reopening menu filter for non-nullable DateTimeOffset column” in our 30.1.38 release.  So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the NuGet package for the latest fixes and features below.


NuGet : https://www.nuget.org/packages/Syncfusion.Blazor.Grid

Root cause : Type casting done to convert to DateTimeOffset.

Action Taken:  Removed Casting and used the value as it is always.


Marked as answer

MI Mike-E August 26, 2025 10:19 AM UTC

Great!  Thank you so much Prathap for your efforts.  I can confirm that filtering works as expected now. 👍



SK Sanjay Kumar Suresh Syncfusion Team August 27, 2025 03:27 AM UTC

Hi Mike-E,


We are happy to hear that the provided solution was helpful. Please get back to us if you need any other assistance.


Regards,

Sanjay Kumar Suresh


Loader.
Up arrow icon