sfDataGrid Sort Descriptor shows the sort on header but no sort is done

Hi,

I wanted to sort the data of a column programmatically, the header row shows the arrow indicating the sorting on the wanted direction, but the data is not sorted (the data is a collection).
If then I click to sort the sorting is done, any idea?


I have .NET8, Syncfusion 27.2.2, Windows 11.


Thanks


9 Replies 1 reply marked as answer

MA Manikanda Akash Munisamy Syncfusion Team November 18, 2024 12:28 PM UTC

Hi Daniele Wyss,

We have reviewed your requirement to sort a column programmatically, where you observed that only the header row displays the sort arrow without sorting the data. To replicate the issue, we created a SortColumnDescription for the specific column and added it to the SfDataGrid's SortColumnDescriptions programmatically in a simple sample. However, we were unable to reproduce the reported behavior. For your reference, we have attached the prepared sample.


Output Image:


If our approach to replicating the issue differs from yours, kindly share the exact replication steps. Additionally, if possible, please provide a video reference demonstrating the issue to help us understand it better and provide a prompt solution.
 
If we have misunderstood your requirements or if further clarification is needed, please do not hesitate to reach out.
 
Thank you for your cooperation.
 
Regards,
Manikanda Akash

Attachment: SfDataGrid_Net80_3f7e5eb8.zip


DW Daniele Wyss November 18, 2024 12:47 PM UTC

Hi,

thanks to take time to check this issue.

I looked you example and made running, the sorting on your example is working.

While looking your example I thought to try to make sorting on another column, and with this one is working.

So my problem is that it is working with a string type but not working with a type DateTime.

Where I can find a description of hot to sort a DateTime progra



MA Manikanda Akash Munisamy Syncfusion Team November 19, 2024 11:51 AM UTC

Hi Daniele Wyss, 
 
Based on the details provided, we have modified the sample by adding a DateTime property to the Model class and programmatically sorted it in ascending order during the initial loading. The date values are being sorted correctly as expected. The modified sample has been attached for your reference.


Output Image:


If you still face any issues or require further assistance, please do not hesitate to contact us.

Regards,
Manikanda Akash

Attachment: SfDataGrid_Net8.0_6f2bc96e.zip


DW Daniele Wyss November 25, 2024 09:56 AM UTC

Hi,

the sorting par looks the same on my side, I also tried to generate random dates like you did, but not working.

I tried to copy most of settings from my side to you example but it is always working with yours, the key difference I see that I did not test is to put the sfDatagrid to a TabControlAdv.

What may help to identify where I do something wrong is this effect:
As soon as I insert with the user interface a character to a filter row cell the entries are suddenly automatically showed sorted correctly by date...



MA Manikanda Akash Munisamy Syncfusion Team November 26, 2024 12:48 PM UTC

Hi Daniele Wyss,
 
Based on the details provided, we understand that you have tested our sample with your implementation, and it works in all cases. Since you mentioned that you have placed the SfDataGrid within a TabControlAdv but have not yet tested this specific scenario, we have modified our application to include the grid within a TabControlAdv.
 
In this modified scenario, date values are sorted as expected on the initial load itself, without requiring any additional UI updates. For your convenience, we have attached the modified sample for your reference.
 
If you have any additional concerns or need further assistance, please do not hesitate to reach out to us.
 
Thank you for your cooperation.

Regards,
Manikanda Akash

Attachment: SfDataGrid_Sorting_76765223.zip


DW Daniele Wyss replied to Manikanda Akash Munisamy November 27, 2024 09:18 AM UTC

I probably found where is the difference.

On my case I have a OrderInfo "ObservableCollection" and not a "List".

I define the sorting before to add the orders to the collection.

I tried to apply the sorting after adding all the OrderInfo to the collection and the sorting is correct.

Is it normal that when adding an orderinfo to an  "ObservableCollection" the new added order is presented at the bottom and the active sorting has no effect on this new entry ?




MA Manikanda Akash Munisamy Syncfusion Team November 28, 2024 06:47 AM UTC

Hi Daniele Wyss,
 
Could you please check if defining the LiveDataUpdateMode for your grid resolves the issue? For more details, please refer to the documentation:

Regards,
Manikanda Akash

Marked as answer

DW Daniele Wyss replied to Manikanda Akash Munisamy November 28, 2024 07:28 AM UTC

Hi,

this solved my problem, I added

sfDataGrid1.LiveDataUpdateMode = LiveDataUpdateMode.AllowDataShaping;


Thanks for the super support.



MA Manikanda Akash Munisamy Syncfusion Team November 28, 2024 07:36 AM UTC

Hi Daniele Wyss,

We are glad that your issue was resolved. Hence, we mark this forum as solved. Please feel free to create a new forum, and we will be happy to assist you.

Regards,
Manikanda Akash

Loader.
Up arrow icon