DataGrid Sorting not working for columns with DateOnly values

DataGrid Sorting not working for columns with DateOnly values. 


On clicking on the header nothing happens, other columns with string, double, etc. are working fine


3 Replies

NY Nirmalkumar Yuvaraj Syncfusion Team August 1, 2023 11:41 AM UTC

Hi Andreas,


We have conducted extensive tests using the provided information , and we were unable to reproduce the reported issue. During our testing, we observed that the DataGridDateColumn can be sorted as expected. We kindly request you to review the modified sample attached in this response along with the accompanying output reference video for your reference.


Regards,

Nirmalkumar


Attachment: SfDataGridDebug_a3de3809.zip


AN Andreas August 1, 2023 01:19 PM UTC

hy in your example you are using DateTime not DateOnly objects -> i see the issue with DateOnly objects



NY Nirmalkumar Yuvaraj Syncfusion Team August 2, 2023 10:45 AM UTC

Andreas ,


Upon analyzing the information, you provided, We performed extensive testing using the provided sample. As a result, we successfully replicated the mentioned issue. Currently, SfDataGrid does not offer support for DateOnly types. However, rest assured that this feature will be included in our upcoming 2023 vol 3 release, anticipated for the end of September. We appreciate your patience and understanding until then. You can follow up with the below feedback for further details, 


Feedback link - https://www.syncfusion.com/feedback/45815/provide-support-to-bind-dateonly-type-data-in-datagriddatecolumn


In the meantime, you can implement the following workaround to achieve sorting functionality for DateOnly types. We have included a sample for your reference.


Code snippet:

XAML

<syncfusion:SfDataGrid x:Name="dataGrid"

                       ItemsSource="{Binding Employees}"

                       AutoGeneratingColumn="dataGrid_AutoGeneratingColumn"

                       SortingMode="Multiple">

</syncfusion:SfDataGrid>

 

C#

private void dataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)

{

               if (e.Column.MappingName == "HireDate")

               {

                              e.Cancel = true;

                              dataGrid.Columns.Add(new DataGridDateColumn() { MappingName = "HireDate" });

               }

 

}


Regards,

Nirmalkumar


Attachment: SfDataGridDebug_12bfa1d0.zip

Loader.
Up arrow icon