Value type timestamp with time zone is not filterable on datagrid
Hello, I have an issue with filtering on DataGrid. As per my 1st screenshot, you can see that the grid and filter match the values
but after selecting one of these dates the grid returns no records to display
Data is loaded from the database CreatedDateTime is a type of timestamp with time zone
@inject UserProfileService UserProfileService
@using Syncfusion.Blazor.Notifications
@using Syncfusion.Blazor.Buttons
@using System.Text.RegularExpressions;
@using System.Globalization;
<SfGrid DataSource="@Orders" AllowResizing AllowFiltering AllowSorting AllowPaging AllowSelection
Height="100vh" AllowGrouping AllowReordering EnablePersistence EnableAutoFill>
<GridPageSettings PageSize="15" />
<GridSortSettings AllowUnsort="true" />
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel" />
<GridColumns>
<GridColumn AutoFit TextAlign="TextAlign.Left" Field="@nameof(Order.CreatedDateTime)" HeaderText="Processing Date" Format="@formattedDateTime" Type="ColumnType.DateTime" />
<GridColumn AutoFit TextAlign="TextAlign.Left" Field="@nameof(Order.Date)" HeaderText="Value date" Format="@userDateFormat" Type="ColumnType.DateTime" />
<GridColumn AutoFit TextAlign="TextAlign.Right" Field="@nameof(Order.Amount)" HeaderText="Amount">
<Template Context="data">
@FormatNumber(((Order)data).Amount, userCurrencyFormat)
</Template>
</GridColumn>
<GridColumn AutoFit TextAlign="TextAlign.Left" Field="@nameof(Order.CurrencyCode)" HeaderText="Currency"></GridColumn>
</GridColumns>
</SfGrid>
@code {
UserProfile? userProfile;
private string? userDateFormat;
private string? userTimeFormat;
private string? userCurrencyFormat;
private string? formattedDateTime;
[Parameter] public IEnumerable<Order>? Orders { get; set; }
protected override async Task OnInitializedAsync()
{
userProfile = await UserProfileService.GetUserProfileS3Async();
userDateFormat = userProfile.DateFormat;
userTimeFormat = userProfile.TimeFormat;
userCurrencyFormat = userProfile.CurrencyFormatType; ;
formattedDateTime = $"{userProfile.DateFormat} {userProfile.TimeFormat}";
}
public static string FormatNumber(decimal number, string formatType)
{
return formatType switch
{
"en-US" => number.ToString("N2", CultureInfo.CreateSpecificCulture("en-US")), // 1,234.56
"fr-FR" => number.ToString("N2", CultureInfo.CreateSpecificCulture("fr-FR")), // 1 234,56
"de-DE" => number.ToString("N2", new CultureInfo("de-DE")), // 1.234,56
"de-CH" => number.ToString("N2", CultureInfo.CreateSpecificCulture("de-CH")), // 1'234.56
"sv-SE" => number.ToString("N2", CultureInfo.CreateSpecificCulture("sv-SE")), // 1 234.56
"mn-Mong-MN" => number.ToString("N2", CultureInfo.CreateSpecificCulture("mn-Mong-MN")), // 1,234,56
"gsw-CH" => number.ToString("N2", CultureInfo.CreateSpecificCulture("gsw-CH")), // 1'234,56
"F2" => number.ToString("F2", CultureInfo.InvariantCulture), // 1234.56
_ => number.ToString("N2")
};
}
public class UserProfile
{
public string UserId { get; set; } = String.Empty;
public string DateFormat { get; set; } = "dd-MMM-yyyy";
public string TimeFormat { get; set; } = "hh:mm:ss tt";
public string CurrencyFormatType { get; set; } = "N2";
public string TimeZoneId { get; set; } = "UTC";
}
}
I just found out that the filter is using the default Synsfucion time format instead of provided by me on the grid
When I search for the specific date and time on the default filter (FilterBar) it will append my format to the default syncfusion date time format screenshot 1 and 2 after pressing enter on value 24-Jan-2024 08:01:14 AM
it was updated to value 1/24/2024 08:01:14 AM
Hi Pawel,
Greetings from Syncfusion.
We have prepared a simple sample as per your shared code snippet. But we could not able to reproduce the reported issue at our end. Kindly check the below attached sample and screen snippet for your reference.
|
|
If you still face difficulties then kindly share us the below details from your end.
- Share us the Nuget version used at your end.
- If you are using older version then try upgrading to our latest version and check the reported issue at your end.
- Share us the column type of CreatedDateTime column.
- If possible share us a simple issue reproduceable sample or kindly reproduce the reported issue on the above attached sample.
The above requested details will be very helpful for us to validate the reported issue at our end.
Regards,
Monisha
Hello Monisha,
I think I know where the issue is. I am not using DateTime but DateTime.UtcNow.
Please see a code mockup based on your playground code where I have 2 grids and each of them is displaying different Lists of orders, one of which is using DateTime.
UtcNow
and 2nd which is using DateTime.
@page "/"
@using Syncfusion.Blazor.Grids
<SfGrid DataSource="@OrdersWithUTC" AllowFiltering="true" AllowPaging="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) Format="dd-MMM-yyyy hh:mm:ss tt" HeaderText=" Order Date" Type="Syncfusion.Blazor.Grids.ColumnType.DateTime" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
<SfGrid DataSource="@OrdersWithSimpleDate" AllowFiltering="true" AllowPaging="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) Format="dd-MMM-yyyy hh:mm:ss tt" HeaderText=" Order Date" Type="Syncfusion.Blazor.Grids.ColumnType.DateTime" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public List<Order> OrdersWithUTC { get; set; }
public List<Order> OrdersWithSimpleDate { get; set; }
protected override void OnInitialized()
{
DateTime dt1 = DateTime.UtcNow;
Thread.Sleep(1000);
DateTime dt2 = DateTime.UtcNow;
Thread.Sleep(1000);
DateTime dt3 = DateTime.UtcNow;
Thread.Sleep(1000);
OrdersWithUTC = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = (new DateTime[] { dt1, dt2, dt3 })[new Random().Next(3)]
}).ToList();
OrdersWithSimpleDate = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = (new DateTime[] { new DateTime(2010, 5, 1), new DateTime(2010, 5, 2), new DateTime(2010, 5, 3), })[new Random().Next(3)]
}).ToList();
}
public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime OrderDate { get; set; }
public double? Freight { get; set; }
}
}
Hi Pawel,
We would like to inform you that this problem is due to filtering the time and seconds using the DateTime.Now property. i.e.) the filter value varies by seconds in this scenario. So, while filtering it does not match with the value generated and results in “No Records to Display”.
It is not feasible to manipulate the time and seconds while using the Now property in the following manner. So This approach is not feasible to filter the column.
Please let us know if you have any concerns.
Regards,
Monisha
Hello Monisha,
Thanks for the prompt response.
So what would be the best solution to solve my problem? As in my case once the order is created it is added to the database using Utc.Now to avoid the Daylight Saving Time Issue I am doing time calculations for different timezones.
First of all, if it would not be possible to use it as I intended to do why it is displaying the actual value on filters, but now the value when it is selected?
Can I have an update on this, please?
Hi Pawel,
Sorry for the delay in getting back to you. We are checking the possibility in fixing the reported issue at source end. We will update further details within 13th February 2024. Until then we appreciate your patience.
Hi Pawel,
We have confirmed this as an issue and logged the defect report “Filtering is not working properly for Non nullable columns when data source is DateTime.now” for the same and this fix will be included in our upcoming patch release which is expected to be rolled out in any of our upcoming release.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
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. Until then we appreciate your patience.
Regards,
Monisha
Hello Monisha,
Thank you for that I will keep my eye on this!
Kind regards,
Hi Pawel,
We are glad to announce that, we have included the fix for the issue “Filtering is not working properly for Non nullable columns when data source is DateTime.now” in our 24.2.7 release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the Nuget package for latest fixes and features from below.
Nuget : https://www.nuget.org/packages/Syncfusion.Blazor.Grid
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.
Regards,
Monisha
- 10 Replies
- 2 Participants
- Marked answer
-
PS Pawel Szpytma
- Jan 26, 2024 10:46 AM UTC
- Feb 21, 2024 02:07 PM UTC